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

Allow resolvers to be passed into MockedProvider and set a default #2825

Merged
merged 2 commits into from
Feb 27, 2019

Conversation

hwillson
Copy link
Member

@hwillson hwillson commented Feb 27, 2019

After the changes in apollographql/apollo-client#4499, when MockedProvider is currently used it doesn't have any resolvers set. This means @client directives are passed into the link chain. Since we don't currently allow people to modify the link chain that MockedProvider uses, it's safe to assume people won't want this behaviour, as they can't test things like apollo-link-state this way. This PR sets a default resolvers value of {} to enable AC 2.5's new local state handling, and opens the door for passing custom resolvers into the MockedProvider via props.

Helps with apollographql/fullstack-tutorial#73.

After the changes in apollographql/apollo-client#4499,
when `MockedProvider` is currently used it doesn't have any
`resolvers` set. This means `@client` directives are passed into
the link chain. Since we don't currently allow people to modify the
link chain that `MockedProvider` uses, it's safe to assume people won't
want this behaviour, as they can't test things like `apollo-link-state`
this way. This commit sets a default `resolvers` value of `{}` to
enable AC 2.5's new local state handling, and opens the door for
passing custom resolvers into the `MockedProvider` via props.

Helps fix apollographql/fullstack-tutorial#73.
@hwillson hwillson self-assigned this Feb 27, 2019
@hwillson hwillson merged commit e4a5b68 into master Feb 27, 2019
@hwillson hwillson deleted the hwillson/allow-mocked-resolvers branch February 27, 2019 14:06
@Gongreg
Copy link

Gongreg commented Feb 28, 2019

Hey @hwillson, after updating from 2.5.0 to 2.5.1 I am now getting empty responses after I've mocked apollo provider and passed my own resolvers. I am not using apollo-link-state anymore.

2.5.0 version returns proper result but it warns in console that:

Found @client directives in query but no client resolvers were specified. You can now pass apollo-link-state resolvers to the ApolloClient constructor.

Also if I pass null to resolvers in v2.5.1 it also works but still gives the warning.

@hwillson
Copy link
Member Author

Interesting - thanks for the head up @Gongreg, I'll take a look.

@hwillson
Copy link
Member Author

hwillson commented Mar 2, 2019

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