diff --git a/package.json b/package.json index 9a4f2909fa..785f486d45 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "test": "npm run lint && npm run check && npm run testonly && npm run prettier:check && npm run check:spelling && npm run check:integrations", "lint": "eslint --cache --max-warnings 0 .", "check": "tsc --pretty", - "testonly": "mocha --full-trace src/**/__tests__/**/*-test.ts -g 'SemanticNonNull halts null propagation'", + "testonly": "mocha --full-trace src/**/__tests__/**/*-test.ts -g 'SemanticOptional allows null values'", "testonly:cover": "c8 npm run testonly", "prettier": "prettier --write --list-different .", "prettier:check": "prettier --check .", diff --git a/src/execution/__tests__/executor-test.ts b/src/execution/__tests__/executor-test.ts index 955a5417a9..0be5c672b4 100644 --- a/src/execution/__tests__/executor-test.ts +++ b/src/execution/__tests__/executor-test.ts @@ -1472,10 +1472,54 @@ describe('Execute: Handles Semantic Nullability', () => { }); it('SemanticOptional allows null values', async () => { + const data = { + a: () => null, + b: () => null, + c: () => 'Cookie' + }; + + const document = parse(` + query { + a + } + `); + const result = await execute({ + schema: new GraphQLSchema({ query: DataType }), + document, + rootValue: data, + }); + + expect(result).to.deep.equal({ + data: { + a: null + } + }); }); it('SemanticOptional allows non-null values', async () => { + const data = { + a: () => 'Apple', + b: () => null, + c: () => 'Cookie' + }; + + const document = parse(` + query { + a + } + `); + const result = await execute({ + schema: new GraphQLSchema({ query: DataType }), + document, + rootValue: data, + }); + + expect(result).to.deep.equal({ + data: { + a: 'Apple' + } + }); }); });