Skip to content

incremental delivery: inline available payloads #3895

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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
863 changes: 706 additions & 157 deletions src/execution/IncrementalPublisher.ts

Large diffs are not rendered by default.

753 changes: 456 additions & 297 deletions src/execution/__tests__/defer-test.ts

Large diffs are not rendered by default.

22 changes: 18 additions & 4 deletions src/execution/__tests__/executor-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { inspect } from '../../jsutils/inspect.js';
import { Kind } from '../../language/kinds.js';
import { parse } from '../../language/parser.js';

import type { GraphQLResolveInfo } from '../../type/definition.js';
import {
GraphQLInterfaceType,
GraphQLList,
Expand Down Expand Up @@ -191,7 +192,7 @@ describe('Execute: Handles basic execution tasks', () => {
});

it('provides info about current execution state', () => {
let resolvedInfo;
let resolvedInfo: GraphQLResolveInfo | undefined;
const testType = new GraphQLObjectType({
name: 'Test',
fields: {
Expand All @@ -213,7 +214,7 @@ describe('Execute: Handles basic execution tasks', () => {

expect(resolvedInfo).to.have.all.keys(
'fieldName',
'fieldNodes',
'fieldDetails',
'returnType',
'parentType',
'path',
Expand All @@ -222,6 +223,9 @@ describe('Execute: Handles basic execution tasks', () => {
'rootValue',
'operation',
'variableValues',
'priority',
'deferPriority',
'published',
);

const operation = document.definitions[0];
Expand All @@ -234,14 +238,24 @@ describe('Execute: Handles basic execution tasks', () => {
schema,
rootValue,
operation,
priority: 0,
deferPriority: 0,
published: true,
});

const field = operation.selectionSet.selections[0];
expect(resolvedInfo).to.deep.include({
fieldNodes: [field],
path: { prev: undefined, key: 'result', typename: 'Test' },
variableValues: { var: 'abc' },
});

const fieldDetails = resolvedInfo?.fieldDetails;
assert(fieldDetails !== undefined);

const field = operation.selectionSet.selections[0];
expect(fieldDetails[0]).to.deep.include({
node: field,
target: undefined,
});
});

it('populates path correctly with complex types', () => {
Expand Down
6 changes: 4 additions & 2 deletions src/execution/__tests__/mutations-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,19 @@ describe('Execute: Handles mutation execution ordering', () => {
first: {},
second: { theNumber: 2 },
},
pending: [{ path: ['first'], label: 'defer-label' }],
hasNext: true,
},
{
incremental: [
{
label: 'defer-label',
path: ['first'],
data: {
promiseToGetTheNumber: 2,
},
},
],
completed: [{ path: ['first'], label: 'defer-label' }],
hasNext: false,
},
]);
Expand Down Expand Up @@ -312,12 +313,12 @@ describe('Execute: Handles mutation execution ordering', () => {
data: {
second: { theNumber: 2 },
},
pending: [{ path: [], label: 'defer-label' }],
hasNext: true,
},
{
incremental: [
{
label: 'defer-label',
path: [],
data: {
first: {
Expand All @@ -326,6 +327,7 @@ describe('Execute: Handles mutation execution ordering', () => {
},
},
],
completed: [{ path: [], label: 'defer-label' }],
hasNext: false,
},
]);
Expand Down
Loading