-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Supply custom headers to queries #521
Comments
Yep - you can do it the same way. Have you tried it? |
Can the header value dynamically assigned upon |
@fikriauliya it's not currently possible to pass additional parameters to query that are passed to the middleware layer. Could you describe your use-case? |
I have multiple GraphQL endpoints. As suggested #84 (comment), instead of creating multiple Apollo client, I created a proxy server to dispatch a GraphQL query to the corresponding server. The way the proxy determine where to dispatch to is by HTTP header
|
I think the goal of doing the proxying on the server should be that the client is not aware of which server it is talking to. Perhaps you can use the root field names of the query? I feel like hard coding which graphql service you are talking to in each component might make things very hard to change down the road. |
Thought about the same as well @stubailo . But I think there are two problems with that approach:
and
|
Rethinking again, my approach above couldn't handle single query which need to retrieve from multiple servers:
Now I am thinking to use approach (2) above: Instead of having simple Nginx proxy server, put GraphQL proxy server on top of Nginx, decode the JSON query, and dispatch based on JSON query. Or do you have better alternatives? |
Came across this, also. Basically looking to aggregate many data sources under a single graphql api. Eg. some rest, but also some graphql endpoints ala api gateway'ish. Coming to similar conclusion of having resolvers that dispatch to different network interfaces/connectors. so Completely off base? |
set header value dynamically is messy SERVER:
CLIENT:
|
The documentation shows how to add a authorization header:
Supply
req.options.headers.authorization
in a middleware.How can we add a custom header
my-custom-header
with valueheader:header-value
to all queries?The text was updated successfully, but these errors were encountered: