New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically set headers when calling Client#parse
#210
Comments
|
You can set up your client to accept headers like this We do this for all our authenticated APIs and it works great. Let me know if that doesn't answer your question though, I might be misunderstanding. |
|
Of course, I just saw an identical answer on #192 which you referenced |
Client#parseClient#parse
|
Yeah this is definitely a weird one. I think it's related to how the ruby object model loads classes/modules, but I'm not sure about that. I'll throw up a server with steps to reproduce. It seems like a simple config memoization will do the trick. Thanks for getting back to me on this one. |
|
@ericyd So maybe "throwing up a server" was a little ambitious on my part. So I'll just copy the errors I'm getting. In order to retrieve the schema, I need to be able to pass a JWT at the initialization of the client. Also when defining queries using the client. The initialization query can't be preformed unless a jwt is passed. Is there any way to fix this, or should I perhaps look at another gem? |
|
Thanks for the STR @wandy-dev , that makes the issue more clear. I'll be honest, I'm not really a contributor to this repo, the author solved a problem for me so I was trying to address some low hanging fruit in the issues as a thank you. My gut instinct on how to solve this is to load a static schema rather than populating it with an introspection query, which is what the An example of how to do this is shown in the README under Configuration: https://github.com/github/graphql-client#configuration to I think your post demonstrates an interesting issue though and bears further investigation. I imagine there is a way to solve this but have not dived deep enough into the code to figure it out right now. |
|
Try: |
|
So obviously this is no longer a priority for me. I'm no longer at the organization that I needed to raise this issue for. If you would like to close it that's fine by me. |
wandy-dev commentedJun 20, 2019
This is related to #192 but I think it warrants it's own issue.
Our api has the schema behind authorization as well. So this example for setting up a query in the readme would also require
contextas an argument.But if we look at the source code for the
parsemethod we can see that there is no such option.graphql-client/lib/graphql/client.rb
Line 105 in b9cbc72
Is there any way to pass headers when defining queries? It seems to me that either every method implemented by
lib/graphql/client.rbneeds to have the context argument, or there needs to be a way to set it dynamically when the class gets initialized.If there isn't currently a way to pass headers through the parse method, I'm going to have to write a wrapper that functions a bit differently from the one in the readme.
The text was updated successfully, but these errors were encountered: