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

Extend ApolloProvider and graphql API to support multiple clients. #481

Closed
wants to merge 1 commit into from

Conversation

1st8
Copy link

@1st8 1st8 commented Feb 24, 2017

Related discussion: #464
Documentation PR: https://github.com/apollographql/react-docs/pull/163

TODO:

  • If this PR is a new feature, reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass
  • Update CHANGELOG.md with your change
  • If this was a change that affects the external API, update the docs and post a link to the PR in the discussion

@apollo-cla
Copy link

@1st8: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@1st8 1st8 force-pushed the feature/multiple-clients2 branch from 488af0a to a287f7b Compare February 24, 2017 12:36
1st8 added a commit to 1st8/react-docs that referenced this pull request Feb 24, 2017
@calebmer
Copy link
Contributor

I’m still opposed to this design 😣

  1. It is a feature that assume a certain use case instead of a general feature that gives users the highest power to do what they want.
  2. use is static.
  3. It complicates ApolloProviders alternate usage as a Redux context provider.
  4. It is challenging to maintain and extend by adding new features which also require plucking the client off of context.

I’m more interested in providing the basic tools to make this implementation possible and have specific use/as semantics implemented outside of react-apollo in a user’s codebase or in a community maintained package.

It’s unfortunate that we had to remove the prop behavior in the past because of prop naming collisions (see commit: 626dbb7), so instead of reintroducing that we should add client to the options function which can be computed from props. Such a design may look like so:

graphql(query, {
  options: props => ({ client: ... }),
})(MyComponent)

If a client does not exist, or it is null then we use the client from context. This is the minimum we can add to enable the maximum number of use cases including enabling you to build this functionality into a community maintained package.

Thoughts?

@jbaxleyiii
Copy link
Contributor

@calebmer I'm good with the options version

@helfer
Copy link
Contributor

helfer commented Feb 28, 2017

I'd be okay with the options way that @calebmer proposed.

@1st8
Copy link
Author

1st8 commented Mar 1, 2017

I won't be preparing a new PR in the near future (vacation coming up 🎉 ).
Changing this one doesn't make sense as well.
Still think that I don't want any clients in my props, but maybe thats just me.

Thanks for your time and feedback, I am gonna go ahead and close this.

@1st8 1st8 closed this Mar 1, 2017
@flexzuu
Copy link
Contributor

flexzuu commented May 26, 2017

Hey I implemented changes proposed by @calebmer. Currently i can't get the test-setup to work. #717
But my integration-test in a simple create-react-app is working fine. I will open a new PR linking to this one and #464 once the testing issue is resolved. Will add a PR to document the feature aswell.
PR is now Open: #729

@flexzuu flexzuu mentioned this pull request May 26, 2017
6 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants