graphql-js
Semantic nullability document directive
#4271
Open

Semantic nullability document directive #4271

twof wants to merge 31 commits into graphql:16.x.x from twof:SemanticNullabilityDocumentDirective
twof
twof236 days ago
No description provided.
benjie New GraphQLSemanticNonNull type
7ca49b2e
benjie Handle isNonNullType
16a2114f
benjie More fixes
2b13389e
benjie More fixes
04a8e915
benjie Yet more updates
076a7356
benjie Recognize in introspection, enable disabling null bubbling
c2196a05
benjie Lint fixes
f5880469
benjie More missing pieces
fa3f1778
benjie More fixes
b5e81bdd
benjie Fix schema
1f6a0197
benjie Fix another test
491f49b6
benjie More minor test fixes
3a91590c
benjie Fix introspection test
56db880c
benjie Add support for * to lexer
593ce448
benjie Allow specifying errorPropagation at top level
13119060
benjie Factor into getIntrospectionQuery
9d706d2d
benjie Lint
e9f9628a
benjie Prettier
eb9b6c8a
twof parser tests passing
3a900a9c
twof Add semantic optional type
557a9866
twof printer and parser tests passing
95484ba2
twof some new semanticNullability execution tests
07e4646c
twof SemanticNonNull halts null propagation
6fac3b53
twof SemanticOptional cleared
d11a6472
twof logging cleanup
0a8b68f0
twof rename to SemanticNullable
24474fa8
twof better SemanticNullable docs
af58560d
twof
twof commented on 2024-11-08
src/execution/__tests__/executor-test.ts
1365 rootValue: data,
1366 });
1367
1368
let executable = document.definitions?.values().next().value as ExecutableDefinitionNode;
1369
let selectionSet = executable.selectionSet.selections.values().next().value;
twof227 days ago

These are just tests so it's not the biggest deal, but is there a better way to retrieve the node for use in error construction? This is workable, but unwieldy.

yaacovCR227 days agođź‘€ 1

Because we do not yet enable noUncheckedIndexAccess (see #3867) I think you could just index it via 0 at this point although I think what you are doing is preferred, for example

const [responseName, fieldNodes] = [...rootFields.entries()][0];

Has been changed in main to your method.

You could assert that you have an executable definition or selection node instead of using typescript casting….

In fact, I think that needs to be improved in main for the example I gave!

const firstRootField = groupedFieldSet.entries().next().value as [

yaacovCR227 days ago

export function isExecutableDefinitionNode(

yaacovCR225 days ago

Paid greater attention when working on twof#5 and I think the answer is that generally the tests use expectJSON and some other testing deduplication, added second commit there demonstrating use.

twof move semantic nullability tests to their own file
668f3dcb
twof fix git status
63345dee
twof run prettier
c472b9e4
twof twof marked this pull request as ready for review 227 days ago
twof twof requested a review 227 days ago
twof Add comment to parser about document directive
163785d2
twof
twof227 days ago (edited 227 days ago)👍 1

Notes for reviewers

I'm looking for review on everything but utilities. I'm going to let @benjie handle those. Once I've been given a go ahead on the implementation, I'll write the spec edits.

There are a large number of files failing linting. Let me know if there's anything I need to do to fix that.

Coverage is passing on my machine. Unclear why it's not passing CI. It also seems to be treating one of my new test files as uncovered code.

yaacovCR
yaacovCR227 days ago

Is there a reason for the introduction of two new wrapping types as opposed to a single one? Is it because of an unresolved syntax question or is it expected to remain in the final implementation?

I could see this being useful if we were to actually allow multiple coexisting syntax variants as dictated by arguments on the semantic nullability directive (but I am not in favor of that additional complexity).

twof
twof227 days ago

Is there a reason for the introduction of two new wrapping types as opposed to a single one? Is it because of an unresolved syntax question or is it expected to remain in the final implementation?

I could see this being useful if we were to actually allow multiple coexisting syntax variants as dictated by arguments on the semantic nullability directive (but I am not in favor of that additional complexity).

In the first commit with the parsing implementation I had a single type.

The printer was the main driver here. In the parser there was a clear place to set the useSemanticNullability mode flag, but with the printer it wasn't so obvious.

BoD
BoD commented on 2024-11-08
src/language/parser.ts
740754 * - NamedType
741755 * - ListType
742756 * - NonNullType
757
* - SemanticNonNullType
BoD227 days ago
Suggested change
* - SemanticNonNullType
* - SemanticNonNullType
* - SemanticNullableType
yaacovCR
yaacovCR225 days ago

The printer was the main driver here. In the parser there was a clear place to set the useSemanticNullability mode flag, but with the printer it wasn't so obvious.

I raised twof#5 as a proof-of-concept for what it might look like with a single new wrapper type.

I stored within the created GraphQLSchema whether it was created usingSemanticNullability and built printing and execution related changed off of that flag.

You can add in semantically nullable types even in a schema that is not using usingSemanticNullability and they will be ignored. In particular, to remain with simply one version of the Introspection types, I modified the built-in Introspection types where I thought to be appropriate to use the new GraphQLSemanticNullable wrapping types; these types are unwrapped but otherwise ignored even when usingSemanticNullability is not set.

Login to write a write a comment.

Login via GitHub

Reviewers
Assignees
No one assigned
Labels
Milestone