Skip to content
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
merged 1 commit into from
Oct 14, 2022

Conversation

BPScott
Copy link
Member

@BPScott BPScott commented Oct 7, 2022

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 an act 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 by await 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 using useQuery from either @shopify/react-graphql or @apollo/client. Test cases pass sucessfully using @testing-library, mocking using @apollo/client/testing and with useQuery from @shopify/react-graphql and @apollo/client. Test cases fail when using @testing-library, mocking using @shopify/graphql-testing and useQuery from @apollo/client.

@BPScott BPScott force-pushed the graphql-testing-fetch-more-test branch from 04f6bf2 to aae8b03 Compare October 13, 2022 22:51
@BPScott BPScott marked this pull request as ready for review October 13, 2022 23:20
@BPScott BPScott requested a review from a team as a code owner October 13, 2022 23:20
@BPScott BPScott added 🤖 Skip Changelog #gsd:24323 Migration of Apollo 2 to Apollo 3 in Web labels Oct 13, 2022
@BPScott BPScott force-pushed the graphql-testing-fetch-more-test branch from aae8b03 to 0f3a23a Compare October 14, 2022 17:42
@BPScott BPScott merged commit d81ecbe into main Oct 14, 2022
@BPScott BPScott deleted the graphql-testing-fetch-more-test branch October 14, 2022 22:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
#gsd:24323 Migration of Apollo 2 to Apollo 3 in Web 🤖 Skip Changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants