Use session variables in GraphQL queries
See original GitHub issueHi all, it would be great to inject my X-Hasura-User-Id
into my GraphQL query so I can use it to filter through data. E.g, fetching the tasks assigned to my currently authenticated user. Are there any plans to build this?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:55
- Comments:20 (3 by maintainers)
Top Results From Across the Web
Roles & Session variables | Hasura GraphQL Docs
Session variables are key-value pairs returned from the authentication service for ... Hasura allows you to create permission rules that can use any...
Read more >set session variable for Hasura on Query in apollo client ...
I have got a query in apollo graphql, that I want to attach a variable to, in the header of the request. The...
Read more >GraphQL variables in simple terms - LogRocket Blog
In GraphQL, you can use variables to reuse the same query/mutations written by the client, with different arguments.
Read more >Executing Queries - GraphQL Ruby
GraphQL provides query variables as a way to parameterize query strings. If your query string contains variables, you can provide values in a...
Read more >GraphQL: Onsite Sessions - Techdocs
When a new user comes to the app, you can use this method to get a new session. It will return you a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@0x777 one idea is to inject all hasura env vars as optional query variables. I’m not sure what the security implications are, but it could look like this:
These could get whitelisted and configured in the Hasura console
@macalinao I’m not sure how this can be done while adhering to the graphql spec. Any ideas?
@victorferreira I think what the op was suggesting is a case like this: Suppose you have a table/view called
followers
where everyone can read all rows. Now suppose you want to fetch your own followers you would do something like this:with
variables
being{"user_id": your_user_id}
. However it would be nice if you can somehow specify that$user_id
should come from a session variable than having to explicitly specify it.