Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where an empty array returned from fetchMore would rerender with an empty list #11706

Merged
merged 7 commits into from Mar 20, 2024

Conversation

jerelmiller
Copy link
Member

Fixes #11642

When using fetchMore with any suspense hook, an empty array was returned from the query whenever the server returned an empty array. This was because we were attaching the raw server value on the promise and emitting that value. This PR updates the resolved value to call getCurrentResult which contains the full cached result.

Copy link

changeset-bot bot commented Mar 19, 2024

🦋 Changeset detected

Latest commit: e43dbd9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@apollo/client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Mar 19, 2024

size-limit report 📦

Path Size
dist/apollo-client.min.cjs 38.35 KB (+0.02% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" 46.17 KB (+0.01% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" (production) 43.73 KB (+0.01% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" 33.95 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" (production) 31.87 KB (0%)
import { ApolloProvider } from "dist/react/index.js" 1.23 KB (0%)
import { ApolloProvider } from "dist/react/index.js" (production) 1.22 KB (0%)
import { useQuery } from "dist/react/index.js" 5.26 KB (0%)
import { useQuery } from "dist/react/index.js" (production) 4.35 KB (0%)
import { useLazyQuery } from "dist/react/index.js" 5.5 KB (0%)
import { useLazyQuery } from "dist/react/index.js" (production) 4.58 KB (0%)
import { useMutation } from "dist/react/index.js" 3.51 KB (0%)
import { useMutation } from "dist/react/index.js" (production) 2.73 KB (0%)
import { useSubscription } from "dist/react/index.js" 3.19 KB (0%)
import { useSubscription } from "dist/react/index.js" (production) 2.38 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" 5.37 KB (+0.08% 🔺)
import { useSuspenseQuery } from "dist/react/index.js" (production) 4.03 KB (+0.15% 🔺)
import { useBackgroundQuery } from "dist/react/index.js" 4.83 KB (+0.09% 🔺)
import { useBackgroundQuery } from "dist/react/index.js" (production) 3.49 KB (+0.09% 🔺)
import { useLoadableQuery } from "dist/react/index.js" 4.98 KB (+0.06% 🔺)
import { useLoadableQuery } from "dist/react/index.js" (production) 3.63 KB (+0.11% 🔺)
import { useReadQuery } from "dist/react/index.js" 3.12 KB (+0.16% 🔺)
import { useReadQuery } from "dist/react/index.js" (production) 3.06 KB (+0.13% 🔺)
import { useFragment } from "dist/react/index.js" 2.27 KB (0%)
import { useFragment } from "dist/react/index.js" (production) 2.22 KB (0%)

@@ -4795,6 +4795,15 @@ describe("refetch", () => {
describe("fetchMore", () => {
it("re-suspends when calling `fetchMore` with different variables", async () => {
const { query, link } = setupPaginatedCase();
const cache = new InMemoryCache({
typePolicies: {
Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out these type policies were needed all along in some of these tests. The bug that this PR fixes masked this issue which is why these wasn't originally part of these tests.

@jerelmiller
Copy link
Member Author

/release:pr

Copy link
Contributor

A new release has been made for this PR. You can install it with:

npm i @apollo/client@0.0.0-pr-11706-20240319212651

Copy link

netlify bot commented Mar 19, 2024

Deploy Preview for apollo-client-docs ready!

Name Link
🔨 Latest commit 00a0508
🔍 Latest deploy log https://app.netlify.com/sites/apollo-client-docs/deploys/65fa01ff01ca410008b9fb49
😎 Deploy Preview https://deploy-preview-11706--apollo-client-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@alessbell alessbell left a comment

Choose a reason for hiding this comment

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

The type policies in uBQ tests! Makes a lot of sense now :) LGTM 🚀

@github-actions github-actions bot added the auto-cleanup 🤖 label Mar 20, 2024
@jerelmiller jerelmiller merged commit 8619bc7 into main Mar 20, 2024
35 checks passed
@jerelmiller jerelmiller deleted the jerel/issue-11642-empty-array branch March 20, 2024 18:01
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants