Skip to content

Commit

Permalink
SemanticOptional cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
twof committed Nov 8, 2024
1 parent 6fac3b5 commit d11a647
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 .",
Expand Down
44 changes: 44 additions & 0 deletions src/execution/__tests__/executor-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
});
});
});

0 comments on commit d11a647

Please sign in to comment.