This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
graphql-testing: Add test for fetchMore behavior #2434
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When testing Apollo 3 we've found an issue that results in React components not being updated as a result of calling
fetchMore
. It seems that the action that triggers the react rerender with the updated data no longer happens within anact
wrapper and thus awaiting on the result of calling event handler shall no longer trigger an update.This PR contains a test that works in Apollo 2 on the main branch and in the
victor-apollo-three
branch with Apollo 3.0.0 to 3.5.10, but fails as of 3.6.0. My hunch is that the introduction of the failure is related to apollographql/apollo-client#9504 - the cache update now happens outside of the promise chain that was triggered byawait fetchMore()
.Testing in https://codesandbox.io/s/test-fetchmore-in-graphql-testing-8hmjzd has narrowed this down to an issue in
@shopify/graphql-testing
. We can see that desired behaviour works in the browser when usinguseQuery
from either@shopify/react-graphql
or@apollo/client
. Test cases pass sucessfully using@testing-library
, mocking using@apollo/client/testing
and withuseQuery
from@shopify/react-graphql
and@apollo/client
. Test cases fail when using@testing-library
, mocking using@shopify/graphql-testing
anduseQuery
from@apollo/client
.