-
Notifications
You must be signed in to change notification settings - Fork 2k
CCN experiment with execution #3510
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
Conversation
❌ Deploy Preview for compassionate-pike-271cb3 failed.
|
src/execution/execute.ts
Outdated
/* | ||
options: | ||
- pass in field nodes, so we can see which are required | ||
- create a new GraphQL output type to represent required and optional fields | ||
|
||
? on its own marks a field nullable | ||
All ! are caught by the next ?, no matter the level | ||
! + ! = ! | ||
! + ? = 0 | ||
! + ! + ? = 0 | ||
|
||
These are executed top down which means we can't follow a | ||
*/ |
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.
delete
src/execution/execute.ts
Outdated
@@ -662,6 +709,7 @@ function completeValue( | |||
info, | |||
path, | |||
result, | |||
false, |
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.
undo probably
src/execution/execute.ts
Outdated
@@ -714,6 +762,7 @@ function completeListValue( | |||
info: GraphQLResolveInfo, | |||
path: Path, | |||
result: unknown, | |||
isRequiredChain: Boolean, |
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.
undo
src/language/ast.ts
Outdated
// Note: Client Controlled Nullability is experimental | ||
// and may be changed or removed in the future. | ||
readonly required?: ListNullabilityNode | NullabilityDesignatorNode; | ||
readonly isInRequiredChain: Boolean; |
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.
I think this will likely become a new required status instead since it feels like it's another case that isn't nullable or non nullable, but impacts null propagation rules all the same.
src/language/parser.ts
Outdated
// const isRequiredChain: Boolean = ((selectionSet?.selections) ?? []) | ||
// .reduce((accumulator: Boolean, element: SelectionNode) => { | ||
// if (accumulator) { | ||
// return true | ||
// } else if () | ||
// }) |
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.
cleanup
src/language/parser.ts
Outdated
for (const selection of selectionSet?.selections ?? []) { | ||
const field = selection as FieldNode; | ||
if (selection.kind == Kind.FIELD) { | ||
if (field.isInRequiredChain) { | ||
isRequiredChain = true; | ||
break; | ||
} | ||
} |
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.
see if TS has some contains(where:)
method that we can replace this with
The latest changes of this PR are available on NPM as Also you can depend on latest version built from this PR: |
The latest changes of this PR are available on NPM as Also you can depend on latest version built from this PR: |
options: | ||
- pass in field nodes, so we can see which are required | ||
- create a new GraphQL output type to represent required and optional fields | ||
|
||
? on its own marks a field nullable | ||
All ! are caught by the next ?, no matter the level | ||
! + ! = ! | ||
! + ? = 0 | ||
! + ! + ? = 0 | ||
|
||
if propagation path is undefined, that could mean that there are no required fields | ||
or that could mean that there are no optional fields. Path can't represent an empty path | ||
*/ |
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.
cleanup
src/utilities/applyRequiredStatus.ts
Outdated
|
||
while (isListType(getNullableType(typeStack[typeStack.length - 1]))) { | ||
const list = assertListType( | ||
getNullableType(typeStack[typeStack.length - 1]), | ||
); | ||
const elementType = list.ofType as GraphQLOutputType; | ||
typeStack.push(elementType); | ||
} | ||
|
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.
Only populate typeStack after we've confirmed that nullabilityNode
exists to improve performance
@@ -104,4 +104,4 @@ export type { BreakingChange, DangerousChange } from './findBreakingChanges'; | |||
// Wrapper type that contains DocumentNode and types that can be deduced from it. | |||
export type { TypedQueryDocumentNode } from './typedQueryDocumentNode'; | |||
|
|||
export { modifiedOutputType } from './applyRequiredStatus'; | |||
export { applyRequiredStatus as modifiedOutputType } from './applyRequiredStatus'; |
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.
Not sure why I exported this under a different name. Probably revert.
/** | ||
* List element nullability designators need to use a depth that is the same as or less than the | ||
* type of the field it's applied to. | ||
* | ||
* Otherwise the GraphQL document is invalid. | ||
* | ||
* See https://spec.graphql.org/draft/#sec-Field-Selections | ||
*/ |
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.
This validation step isn't accurate. Update to include loosened rules.
}; | ||
|
||
const modified = visit(nullabilityNode, applyStatusReducer); | ||
// modifiers must be exactly the same depth as the field type |
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.
Designators
a3bef80
to
40df6bc
Compare
Hi @twof, are you still championing this work through the GraphQL WG? I'm open to chat about it and contribute to getting this moving forward again. |
Hi @calvincestari! Took me a bit to see this sorry about that. If you're still interested, can you message me in the #client-controlled-nullability channel on the graphql discord? I passed the project on to @fotoetienne but I'm sure he'd appreciate the help. |
Will do. I'm away this week but I'll follow up next week. |
No description provided.