Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Mutation client prop support #1863

Closed
pyromaniac opened this issue Mar 28, 2018 · 3 comments
Closed

Mutation client prop support #1863

pyromaniac opened this issue Mar 28, 2018 · 3 comments

Comments

@pyromaniac
Copy link

Hello, thanks for this awesome client first of all!

We considering to upgrade to 2.1 and we really like newly implemented components, however, during the code review we've noticed that Mutation component doesn't support client passed as props (https://github.com/apollographql/react-apollo/blob/master/src/Mutation.tsx#L117) unlike Query (https://github.com/apollographql/react-apollo/blob/master/src/Query.tsx#L163)

Maybe I'm missing something. Do you have any plans to add client prop support there?
Thanks in advance!

@pyromaniac
Copy link
Author

Never mind, just figured out how to have multiple endpoints with a single client.

@victorgb6
Copy link

Hi @pyromaniac I have landed here looking for information on how to have multiple endpoints with a single client, could you say how you achieve this?
Thanks!

@pyromaniac
Copy link
Author

pyromaniac commented Jun 4, 2018

sure

new ApolloClient({
    link: ApolloLink.from([
      errorLink(),
      ApolloLink.split(
        ({ getContext }) => (getContext().endpoint === 'first'),
        httpLink('/graphql/first'),
        httpLink('/graphql/second')
      )
   ])
})

And then in the HOC:

mutate({
  context: { endpoint: 'first' },
  variables: { ...variables }
})

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants