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

Adds test for #2508 #2524

Merged

Conversation

ajmath
Copy link
Contributor

@ajmath ajmath commented Oct 22, 2018

Adds a test to verify that using queries with @client directives are supported by MockedProvider

Checklist:

  • If this PR is a new feature, please 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
  • If this was a change that affects the external API used in GitHunt-React, update GitHunt-React and post a link to the PR in the discussion.

#2508

Apollo Client 2.5 handles `@client` fields locally, which means
when using local resolvers, `@client` fields aren't sent through
AC's configured link chain. To allow people to upgrade to AC 2.5
painlessly, local `@client` handling has to be enabled by
setting local resolvers. If local resolvers aren't set, the
`@client` field is still sent through the link chain.

`MockedProvider` was updated to include a `resolvers` prop, that
can be used to pass local resolvers into the `ApolloClient`
instance it uses internally for testing. The `resolvers` prop
was given a default value of `{}` however, which means AC's
local resolver support is always enabled, and also means that
`MockedProvider` can't be used for tests that require the
`@client` field to be passed through the link chain. When we hit
Apollo Client 3.0, this won't be necessary, but for now we need
to be flexible about this, since people might have updated to
Apollo Client 2.5, but are still using and testing local state
using `apollo-link-state`.

Long story short, this commit removes the `resolvers` default,
which means by default `MockedProvider` isn't using AC 2.5's new
local state handling. It has to be enabled by prodiving
local resolvers via the `MockedProvider` `resolvers` prop.
Copy link
Member

@hwillson hwillson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the initial test here @ajmath! MockedProvider functionality has changed a bit since you created this test (due to the release of Apollo Client 2.5), but this can still be re-used. LGTM!

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.

2 participants