Skip to content

Add support for the new incremental format in GraphQL 17.0.0-alpha.9 - #12926

Merged
jerelmiller merged 97 commits into
release-4.1-baselinefrom
jerel/new-incremental
Nov 14, 2025
Merged

Add support for the new incremental format in GraphQL 17.0.0-alpha.9#12926
jerelmiller merged 97 commits into
release-4.1-baselinefrom
jerel/new-incremental

Conversation

@jerelmiller

@jerelmiller jerelmiller commented Sep 17, 2025

Copy link
Copy Markdown
Member

Fixes #12245

Adds support for using the @defer directive with the new incremental delivery format as implemented in graphql@17.0.0-alpha.9.

@changeset-bot

changeset-bot Bot commented Sep 17, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 14e5a98

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

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

@apollo-librarian

apollo-librarian Bot commented Sep 17, 2025

Copy link
Copy Markdown
Contributor

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 2721fb02f556da014fcc07d7
Build Logs: View logs

@pkg-pr-new

pkg-pr-new Bot commented Sep 17, 2025

Copy link
Copy Markdown
npm i https://pkg.pr.new/apollographql/apollo-client/@apollo/client@12926

commit: 14e5a98

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (CJS) 43.17 KB (+0.8% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (production) (CJS) 38.14 KB (+0.94% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" 32.68 KB (+0.15% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (production) 26.85 KB (-0.03% 🔽)
import { ApolloProvider } from "@apollo/client/react" 5.97 KB (+1.03% 🔺)
import { ApolloProvider } from "@apollo/client/react" (production) 994 B (0%)
import { useQuery } from "@apollo/client/react" 7.4 KB (+0.7% 🔺)
import { useQuery } from "@apollo/client/react" (production) 2.39 KB (0%)
import { useLazyQuery } from "@apollo/client/react" 7.15 KB (+0.51% 🔺)
import { useLazyQuery } from "@apollo/client/react" (production) 2.16 KB (0%)
import { useMutation } from "@apollo/client/react" 6.53 KB (+0.96% 🔺)
import { useMutation } from "@apollo/client/react" (production) 1.52 KB (0%)
import { useSubscription } from "@apollo/client/react" 6.85 KB (+0.87% 🔺)
import { useSubscription } from "@apollo/client/react" (production) 1.81 KB (0%)
import { useSuspenseQuery } from "@apollo/client/react" 8.62 KB (+0.77% 🔺)
import { useSuspenseQuery } from "@apollo/client/react" (production) 3.63 KB (0%)
import { useBackgroundQuery } from "@apollo/client/react" 8.38 KB (+0.45% 🔺)
import { useBackgroundQuery } from "@apollo/client/react" (production) 3.4 KB (0%)
import { useLoadableQuery } from "@apollo/client/react" 8.35 KB (+0.68% 🔺)
import { useLoadableQuery } from "@apollo/client/react" (production) 3.39 KB (0%)
import { useReadQuery } from "@apollo/client/react" 6.64 KB (+0.73% 🔺)
import { useReadQuery } from "@apollo/client/react" (production) 1.65 KB (0%)
import { useFragment } from "@apollo/client/react" 6.71 KB (+0.77% 🔺)
import { useFragment } from "@apollo/client/react" (production) 1.71 KB (0%)

if (hasDirectives(["defer"], request.query)) {
const context = request.context ?? {};
const http = (context.http ??= {});
http.accept = ["multipart/mixed", ...(http.accept || [])];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A previous comment asked if we should also have a deferSpec identifier here, and the thinking is yes, since that version of the protocol still isn’t guaranteed to end up as the final version.

We were thinking of using 20230621 as the identifier (as a reference to this doc)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These tests weren't actually testing defer but a regular query that emitted multiple values. To be honest, I'm not sure how useful these tests are given this should theoretically never happen in a real application (at least for queries). That said, I just removed the @defer in the queries for now since it was misleading since it wasn't actually testing defer payloads.

).toBeUndefined();
});

it("deduplicates queries as long as a query still has deferred chunks", async () => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've moved @defer tests to their own subfolders. This test still exists in src/core/__tests__/client.watchQuery/defer20220824.test.tsx

Comment thread src/incremental/handlers/graphql17Alpha9.ts
Comment thread src/incremental/handlers/graphql17Alpha9.ts
Comment thread src/link/error/__tests__/index.ts
Comment thread src/react/hooks/__tests__/useQuery/deferGraphQL17Alpha9.test.tsx
@jerelmiller
jerelmiller merged commit 2b7f2c1 into release-4.1-baseline Nov 14, 2025
71 checks passed
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Dec 15, 2025
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.

3 participants