Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Sky-bits/7e49b916b31b754738f27d60c483c059 to your computer and use it in GitHub Desktop.
Save Sky-bits/7e49b916b31b754738f27d60c483c059 to your computer and use it in GitHub Desktop.
Thanks for your interest in helping make Apollo Client better!
Feature requests and non-bug related discussions are no longer managed in this repo. Feature requests should be opened in https://github.com/apollographql/apollo-feature-requests.
i can find into the Office Doc how use more then one endpoint
here is my solution on Apollo react client
` const firstLink = new HttpLink({
uri: 'graphql-postgre',
//headers: yourHeadersHere,
// other link options...
});
const secondLink = new HttpLink({
uri: 'http://localhost:3000/graphqli',
});
const client = new ApolloClient({
link: ApolloLink.split(
(o) => o.getContext().clientName === 'firstlink',
firstLink,
ApolloLink.split((o) => o.getContext().clientName === 'secondlink ',
secondLink )
), // by default -> postgre)
cache: new InMemoryCache(),
fecthOptions: {
mode: 'no-cors',
},
shouldBatch: true,
});`
query `const { loading, error, data } = useQuery(MyQueries, { context: {clientName: 'secondlink'}});
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment