Closed
Description
Follow up from comment from @captbaritone on discord.
The current description of @semanticNonNull
states that:
"""
...
If `level` is null, all levels are semantically non null.
...
"""
directive @semanticNonNull(field: String = null, level: Int = null) repeatable on FIELD_DEFINITION | OBJECT
One advantage is that it's more compact in list cases. Compare:
type User {
# make all levels nullable with a single directive
friends: [Users] @semanticNonNull
}
to
type User {
# making all levels nullable requires several directives
friends: [Users] @semanticNonNull(level: 0) @semanticNonNull(level: 1)
}
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:
type User {
# should that be an error? a warning?
friends: [Users!] @semanticNonNull
}
Since @semanticNonNull
applies to all levels above, it's also applying to User!
, 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
Metadata
Metadata
Assignees
Labels
No labels