Skip to content

Commit d11a647

Browse files
committed
SemanticOptional cleared
1 parent 6fac3b5 commit d11a647

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"test": "npm run lint && npm run check && npm run testonly && npm run prettier:check && npm run check:spelling && npm run check:integrations",
3939
"lint": "eslint --cache --max-warnings 0 .",
4040
"check": "tsc --pretty",
41-
"testonly": "mocha --full-trace src/**/__tests__/**/*-test.ts -g 'SemanticNonNull halts null propagation'",
41+
"testonly": "mocha --full-trace src/**/__tests__/**/*-test.ts -g 'SemanticOptional allows null values'",
4242
"testonly:cover": "c8 npm run testonly",
4343
"prettier": "prettier --write --list-different .",
4444
"prettier:check": "prettier --check .",

src/execution/__tests__/executor-test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,10 +1472,54 @@ describe('Execute: Handles Semantic Nullability', () => {
14721472
});
14731473

14741474
it('SemanticOptional allows null values', async () => {
1475+
const data = {
1476+
a: () => null,
1477+
b: () => null,
1478+
c: () => 'Cookie'
1479+
};
1480+
1481+
const document = parse(`
1482+
query {
1483+
a
1484+
}
1485+
`);
14751486

1487+
const result = await execute({
1488+
schema: new GraphQLSchema({ query: DataType }),
1489+
document,
1490+
rootValue: data,
1491+
});
1492+
1493+
expect(result).to.deep.equal({
1494+
data: {
1495+
a: null
1496+
}
1497+
});
14761498
});
14771499

14781500
it('SemanticOptional allows non-null values', async () => {
1501+
const data = {
1502+
a: () => 'Apple',
1503+
b: () => null,
1504+
c: () => 'Cookie'
1505+
};
1506+
1507+
const document = parse(`
1508+
query {
1509+
a
1510+
}
1511+
`);
14791512

1513+
const result = await execute({
1514+
schema: new GraphQLSchema({ query: DataType }),
1515+
document,
1516+
rootValue: data,
1517+
});
1518+
1519+
expect(result).to.deep.equal({
1520+
data: {
1521+
a: 'Apple'
1522+
}
1523+
});
14801524
});
14811525
});

0 commit comments

Comments
 (0)