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

Document client prop #1588

@estaub

Description

@estaub

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!)

Activity

astorije

astorije commented on Apr 10, 2018

@astorije

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

peaonunes commented on Aug 14, 2018

@peaonunes

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.

changed the title [-][enhancement 2.1] Add client option to new <Query>[/-] [+]Document client prop[/+] on Oct 15, 2018
rosskevin

rosskevin commented on Dec 27, 2018

@rosskevin
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsFocuses on documentation changes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @astorije@rosskevin@danilobuerger@estaub@peaonunes

        Issue actions

          Document client prop · Issue #1588 · apollographql/react-apollo