-
Notifications
You must be signed in to change notification settings - Fork 45
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
How to pass context in query? #55
Comments
There doesn't seem to be a way to override |
@yuki24 So I thought I had a solution but when executing a query it comes through the |
I'm not sure I understand. Would you mind posting a code snippet? |
And assume I called:
So at this point everything works but when calling |
Ok I found an other solution, instead of doing it like above I can do this in my spec:
This will create the current_user context for me. |
Is there something we still want in Graphlient for this? |
@dblock we may want to add the ability to override query = <<-GRAPHQL
query($ids: [Int]) {
...
}
GRAPHQL
variables = {ids: [42]}
client.query(query, variables, context: ...) # Right now this isn't possible |
Makes sense. Maybe someone can try a PR? Wink wink @egonm12 ;) |
@dblock I will look into it. My first try in #55 (comment) didn't work properly as you can see. |
thanks for describing the issue @egonm12 , I wonder what is the use case for updating context per query. When you create the client you can set JWT header with passing hash of headers: Graphlient::Client.new('http://localhost:4000/api/graphql', headers: headers) in your case are you trying to update JWT for one specific query or you want to have the token as a parameter merged into query variables? |
Looks like #58 is related. |
@ashkan18 We have a use case for needing to be able to switch context per query, maybe it helps explain. On the Shopify GraphQL API, each user/store has it's own unique endpoint (url) and bearer token. Hope that makes sense :) |
That seems reasonable to me, want to try to PR this? |
I wish I could, but I don't have the skills :( |
How can I pass the current_user context in a query? In the
execute
method I see:query_params[:context] = @options if @options
.I got this shared_context:
Since I am using query authorization I can't simply query something like:
Because I need the context[:current_user]
The text was updated successfully, but these errors were encountered: