-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Semantic nullability document directive #4271
base: 16.x.x
Are you sure you want to change the base?
Conversation
let executable = document.definitions?.values().next().value as ExecutableDefinitionNode; | ||
let selectionSet = executable.selectionSet.selections.values().next().value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
graphql-js/src/execution/subscribe.ts
Line 217 in 423e72d
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!
graphql-js/src/execution/execute.ts
Line 2241 in 831c121
const firstRootField = groupedFieldSet.entries().next().value as [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
graphql-js/src/language/predicates.ts
Line 24 in 423e72d
export function isExecutableDefinitionNode( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Notes for reviewersI'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. |
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 |
@@ -740,6 +754,7 @@ export class Parser { | |||
* - NamedType | |||
* - ListType | |||
* - NonNullType | |||
* - SemanticNonNullType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* - SemanticNonNullType | |
* - SemanticNonNullType | |
* - SemanticNullableType |
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 You can add in semantically nullable types even in a schema that is not using |
No description provided.