Skip to content

Conversation

jerelmiller
Copy link
Member

Adds support for using the @defer directive with the new incremental delivery format as implemented in [email protected].

Copy link
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
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

@jerelmiller jerelmiller force-pushed the jerel/new-incremental branch from ac7d43f to 7512b6b Compare September 8, 2025 21:29
}
});

it('does not suspend deferred queries with data in the cache and using a "cache-and-network" fetch policy', async () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to react/hooks/__tests__/useBackgroundQuery/defer20220824.test.tsx

@jerelmiller jerelmiller marked this pull request as ready for review September 8, 2025 21:48
if (hasDirectives(["defer"], request.query)) {
const context = request.context ?? {};
const http = (context.http ??= {});
http.accept = ["multipart/mixed", ...(http.accept || [])];
Copy link
Member Author

Choose a reason for hiding this comment

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

We need to figure out what the accept header should be. deferSpec=20220824 doesn't work here anymore, but I don't know if we are replacing it with something else or leaving it bare.

@jerelmiller jerelmiller deleted the branch release-4.1 September 17, 2025 19:22
JoviDeCroock pushed a commit to graphql/graphql-js that referenced this pull request Sep 22, 2025
…endingResult` (#4481)

Fixes #4333 

This change fixes the fields in `FormattedCompletedResult` to match
`CompletedResult` (i.e. `id` and `errors`) using the `Formatted*` type
variants. This change also adds a `FormattedPendingResult` as an
counterpart to `PendingResult` to match the type patterns already
established with other `Formatted*` types.

I ran into this issue when working on adding support for the new
incremental format in Apollo Client
(apollographql/apollo-client#12906).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant