Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
@semanticNonNull
/@catch
: default levels to [0] instead of null #42@semanticNonNull
/@catch
: default levels to [0] instead of null #42Changes from 2 commits
e6c076d
43ad7d1
62f7382
ba09b50
abd6e31
9b54a7b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Unrelated to the main change in this PR, but...
I'm guessing you considered this already, but it would be possible to let regular GraphQL schema validation enforce this invariant for us by making a separate directive for the case where you specify a field, and then have that directive require a field be specified, and removing the argument from the field version.
As it stands we need ad-hoc validation that you do specify a field when used on a type, and that you don't specify a field when used on a field.
That said, I can see that having two directives is also cumbersome.
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.
Makes sense. The less custom validation I have to do, the happier I am.
@semanticNonNullField(field: String!)
feels like a mouthful of "fields" though. Other suggestions:Also thinking about this, we could also remove the
repeatable
from the regular@semanticNonNull
: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.
Yeah, if we make levels plural, then we can remove the repeatable for the FIELD_DEFINITION variant.
@addSemanticNonNull
seem fine!So the remaining validation we need to do:
@addSemanticNonNull
, validate that the field existsIn theory you could end up with a type getting marked as semantically non null in multiple ways. Probably that's okay? As long as it does not confuse tools:
Or
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.
More validation to be done but I think it's ok.
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.
Name nit: I find the word
add
to be a bit off for a directive because in a way all directives add something.semanticNonNullField
works better for me but not a strong opinion.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.
Agree directives are declarative and shouldn't start with a verb. I settled with
@semanticNonNullField(name: String, levels: [Int])
in ba09b50, let me know what you think.Also nitpick but it should really be
@semanticNonNullPosition(field: String, levels: [Int])
but the spec uses field instead of position (or something else) in a lot of places so I keptField
for consistency even if it's a bit wrong.