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

Document client prop #1588

Closed
estaub opened this issue Jan 28, 2018 · 4 comments
Closed

Document client prop #1588

estaub opened this issue Jan 28, 2018 · 4 comments
Labels
docs Focuses on documentation changes

Comments

@estaub
Copy link

estaub commented Jan 28, 2018

Support for the client option on old-school graphql() queries is absent from <Query>.

graphql() options
<Query> options

This may have happened because the client option was never documented.

The original author of the client option PR was silent for 6 months, then posted this, indicating that he's no longer interested in working on it.

If the client option is deprecated, it would probably be good to post something, including a comment on the PR above so that subscribers see it, and a recommended approach to addressing a requirement for multiple clients.

The best way forward may be influenced by the functionality provided by the QueryRecyclerProvider in <ApolloProvider>; I'm afraid I don't understand what it does.

(Thanks!)

@astorije
Copy link

That would be great! We currently have a use case where we need to talk to more than one client, so that would make things cleaner.

@peaonunes
Copy link

The following code line from current version (2.1.9) and both Query and Mutation gives precedence to props client. So we can indeed override the default client via props.

// https://github.com/apollographql/react-apollo/blob/master/src/Query.tsx#L167
// https://github.com/apollographql/react-apollo/blob/master/src/Mutation.tsx#L120
...
this.client = props.client || context.client;
...

You would use like:

<Query query={query} client={client}>
...
</Query>

The feature is not documented though.
In addition to that the most common approach would be having a Gateway API running GraphQL and managing queries to different targets APIs. I wrote this article discussing some approaches if you really want to do that and pointing out some pros and cons.

@lorensr lorensr changed the title [enhancement 2.1] Add client option to new <Query> Document client prop Oct 15, 2018
@rosskevin
Copy link
Contributor

Please PR any docs you would like to see. Client prop is definitely not going away.

@rosskevin rosskevin added the docs Focuses on documentation changes label Dec 27, 2018
@danilobuerger
Copy link
Contributor

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

No branches or pull requests

5 participants