-
Notifications
You must be signed in to change notification settings - Fork 7
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
Change @semanticNonNull.level
and @catch.level
default to be 0
?
#40
Comments
@semanticNonNull.level
default to be 0
?@semanticNonNull.level
and @catch.level
default to be 0
?
My 2c: |
I'm not sure I follow. A type cannot be simultaneously non-nullable and semantically-non-nullable. In other words, following the syntax suggested in @GeNJie's RFC it would be invalid SDL to make a field both non-null and semantic non-null: type User {
name: !String! # Presumably this would be an error
} Following from that observation, and your assessment that nullable list items are rare (I'm inclined to agree), having the default be that we apply to all levels seems likely to invite that conflicting state where we are declaring that a type is both non-nullable and semantically-non-nullable. type User {
# The ! on the list item conflicts with @semanticNonNull applying to all levels
friends: [User!] @semanticNonNull
} As I've looked at supporting The upshot is that I suspect it will be rare to make items within lists For a more detailed breaking of this reasoning see this doc. If my reasoning is sound, then semantic non-null list items will be rare and most schema authors will opt for explicit non-nullable or nullable. But, schema authors will likely still want to mark most plural fields as I think a more sensible mental model for schema authors is: "Slap a |
Ah that actually makes sense - I was seeing this from the lense of our codegen which will generate the field as non nullable in both cases. But it’s true the semantics are incompatible and a warning at least is probably warranted indeed. |
Pull request to change default |
Closed with #42 |
Follow up from comment from @captbaritone on discord.
The current description of
@semanticNonNull
states that:One advantage is that it's more compact in list cases. Compare:
to
A drawback is that it makes the directive definition more complex (
level
is now nullable, this is surprising).Another drawback is that it opens the door to ambiguous behaviour:
Since
@semanticNonNull
applies to all levels above, it's also applying toUser!
, should that be an error?There's a tradeoff of compactness vs explicitness. Since
@semanticNonNull
is itself verbose already maybe the extra verbosity is worth it if it makes things more explicit.See also: apollographql/apollo-kotlin#5462
The text was updated successfully, but these errors were encountered: