Support multiple GraphQL endpoints
See original GitHub issueIs your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I’m always frustrated when […] our app has to hit multiple graphql endpoints. So this is either a question, or if it’s not possible a feature request.
The problem is that our app is using graphql endpoints from more than 1 url.
Describe the solution you’d like
The ability to specify the base url for a graphql.query
.
Currently you define a route like this: graphql.query("MyQuery", () => {})
Not sure exactly what the best api is for this, but here are a couple of options.
- something simple like
graphql.query("MyQuery", () => {}, {baseUrl:"http://example")
graphql.query("MyFooQuery", () => {}, {baseUrl:"http://foo")
- something at a higher level that let’s us map multiple queries:
graphql.urls({
"http://example": [
graphql.query("MyQuery", () => {}), graphql.query("MyOtherQuery", () => {})
],
"http://foo": [
graphql.query("MyFooQuery", () => {}), graphql.query("MyOtherFooQuery", () => {})
]
- open to other options? just need a way to handle multiple GQL endpoints. again, maybe there’s already a way and we can close this issue.
Describe alternatives you’ve considered A clear and concise description of any alternative solutions or features you’ve considered.
Additional context Add any other context or screenshots about the feature request here.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (11 by maintainers)
Top GitHub Comments
While it may sound compelling,
graphql.link
andrest.link
would have significant design difference:graphql.link
adds an extra layer of endpoint matching as a part of its predicate.rest
already matches a request URL against a given endpoint, so the functionality of linking routes to a specific endpoint becomes a matter of a plain abstraction:I wish this was a way we solve a per-endpoint mocking for GraphQL as well, and it may become similar to this in the future.
🎉 that was fast! Thank you @kettanaito !