Skip to content

Commit

Permalink
Null bubbling in shared grouped fieldset test
Browse files Browse the repository at this point in the history
  • Loading branch information
robrichard committed Feb 16, 2024
1 parent 9c90a23 commit 3b12a9c
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions src/execution/__tests__/defer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const hero = {
const c = new GraphQLObjectType({
fields: {
d: { type: GraphQLString },
e: { type: GraphQLString },
nonNullErrorField: { type: new GraphQLNonNull(GraphQLString) },
},
name: 'c',
Expand Down Expand Up @@ -1128,6 +1129,82 @@ describe('Execute: defer directive', () => {
]);
});

it.only('Null bubbling in shared grouped fieldset', async () => {
const document = parse(`
query {
... @defer(label: "A") {
a {
b {
c {
nonNullErrorField
e
}
}
}
}
... @defer(label: "B") {
a {
b {
c {
nonNullErrorField
d
}
}
}
}
}
`);
const result = await complete(document, {
a: { b: { c: { d: 'd', e: 'e', nonNullErrorField: null } } },
});
console.log(JSON.stringify(result, null, 2));

Check warning on line 1160 in src/execution/__tests__/defer-test.ts

View workflow job for this annotation

GitHub Actions / ci / Lint source files

Unexpected console statement
expectJSON(result).toDeepEqual([
{
data: {
a: {},
},
pending: [
{ id: '0', path: [], label: 'A' },
{ id: '1', path: [], label: 'B' },
],
hasNext: true,
},
{
incremental: [
{
data: { a: { b: { c: null } } },
id: '0',
},
],
completed: [
{
id: '0',
errors: [
{
message:
'Cannot return null for non-nullable field c.nonNullErrorField.',
locations: [{ line: 8, column: 17 }],
path: ['a', 'b', 'c', 'nonNullErrorField'],
},
],
},
{
id: '1',
errors: [
{
message:
'Cannot return null for non-nullable field c.nonNullErrorField.',
locations: [{ line: 8, column: 17 }],
path: ['a', 'b', 'c', 'nonNullErrorField'],
},
],
},
],
hasNext: false,
},
]);
});

it('Nulls cross defer boundaries, null first', async () => {
const document = parse(`
query {
Expand Down

0 comments on commit 3b12a9c

Please sign in to comment.