question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support multiple GraphQL endpoints

See original GitHub issue

Is 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.

  1. something simple like
graphql.query("MyQuery", () => {}, {baseUrl:"http://example")
graphql.query("MyFooQuery", () => {}, {baseUrl:"http://foo")
  1. 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", () => {})
  ]
  1. 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:closed
  • Created 3 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
kettanaitocommented, Aug 6, 2020

While it may sound compelling, graphql.link and rest.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:
const github = (path: string) => {
  return `https://api.github.com/v3${path}`
}

rest.get(github(‘/repo/:owner/:name’), resolver)

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.

2reactions
benmonrocommented, Aug 5, 2020

🎉 that was fast! Thank you @kettanaito !

Read more comments on GitHub >

github_iconTop Results From Across the Web

When to use multiple endpoints in GraphQL - LogRocket Blog
Exposing multiple endpoints in GraphQL is not the same as implementing REST — every REST endpoint provides access to a predefined resource or ......
Read more >
Support for multiple schemas (on multiple endpoints) · Issue #84
I need to access two different graphql endpoints from a project, where each endpoint has a different schema.
Read more >
How to use multiple GraphQL endpoints with Urql
If you are familiar with GraphQL you should already have the need to query third party services data in parallel of your main...
Read more >
Using Apollo with multiple Graphql endpoints
Using Apollo with multiple Graphql endpoints · 1- Create HttpLink to each endpoint · 2- Configure Apollo client · 3- finally, when you...
Read more >
Single GraphQL Server with Multiple Endpoints and Databases
A recording of a vscode liveshare session I had with a Patreon subscriber. We go over how to create multiple GraphQL endpoints on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found