hasura data provider - pass token in header before request
I've configured my hasura endpoint so that an Authrization Header must be populated with a value (i.e. bearer token provide by firebase authentication). That token is available via the usePermissions hook. How would I set headers of the graph-ql client after it's been initialized?
I'm thinking I'd modify the dataProvider to accept an additional parameter, that calls the 'setHeader' method of the client.
What do you think?
edited: it looks like i'd use the 'custom' method, or yoink the header logic into the other methods.
4 Replies
xenial-blackOP•3y ago
maybe its possible to use this library, https://react-query-firebase.invertase.dev/
Hey @UsererOfName ,
You can send GraphQLClient instance to your dataProvider ⚡
Example:
https://discord.com/channels/837692625737613362/900755775037767782/988690403215695872
xenial-blackOP•3y ago
Thanks for the suggestion and link; food for thought. Configuring the client within the authProvider will probably be the way to do it... just have to figure out token refresh logic within that provider, and should be good to launch!
You can check examples of GraphqlClient ⚡️