Skip to content

Commit

Permalink
add semanticNonNullField and make levels an array
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin committed Jan 15, 2024
1 parent 62f7382 commit 8bfa87e
Showing 1 changed file with 44 additions and 22 deletions.
66 changes: 44 additions & 22 deletions nullability/v0.2/nullability-v0.2.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,65 +11,87 @@ type User {
}
```
The `field` argument is the name of the field if `@semanticNonNull` is applied to an object type extension:
```graphql
# extend the base schema to make User.email semantically non-null.
extend type User @semanticNonNull(field: "email")
```
`field` is used for client applications that do not control the base schema and must use type extensions.
When used on a field definition, `field` must be null.
The `level` argument indicates what level is semantically non null in case of lists:
The `levels` argument indicates what levels are semantically non null in case of lists:
```graphql
type User {
# friends is semantically non null
friends: [User] @semanticNonNull # same as @semanticNonNull(level: 0)
friends: [User] @semanticNonNull # same as @semanticNonNull(levels: [0])
# every friends[k] is semantically non null
friends: [User] @semanticNonNull(level: 1)
friends: [User] @semanticNonNull(levels: [1])
# friends as well as every friends[k] is semantically non null
friends: [User] @semanticNonNull(level: 0) @semanticNonNull(level: 1)
friends: [User] @semanticNonNull(levels: [0, 1])
}
```
`level` is zero indexed.
`levels` are zero indexed.
Passing a negative level or a level greater than the list dimension is an error.
"""
directive @semanticNonNull(levels: [Int] = [0]) on FIELD_DEFINITION

"""
Indicates that a position is semantically non null: it is only null if there is a matching error in the `errors` array.
In all other cases, the position is non-null.
`@semanticNonNullField` is the same as `@semanticNonNull` but can be used on type system extensions for services
that do not own the schema like client services:
```graphql
# extend the schema to make User.email semantically non-null.
extend type User @semanticNonNullField(name: "email")
```
The `levels` argument indicates what levels are semantically non null in case of lists:
```graphql
# friends is semantically non null
extend type User @semanticNonNullField(name: "friends") # same as @semanticNonNullField(name: "friends", levels: [0])
# every friends[k] is semantically non null
extend type User @semanticNonNullField(name: "friends", levels: [1])
# friends as well as every friends[k] is semantically non null
extend type User @semanticNonNullField(name: "friends", levels: [0, 1])
```
`levels` are zero indexed.
Passing a negative level or a level greater than the list dimension is an error.
See `@semanticNonNull`.
"""
directive @semanticNonNull(field: String = null, level: Int = 0) repeatable on FIELD_DEFINITION | OBJECT
directive @semanticNonNullField(name: String!, levels: [Int] = [0]) repeatable on OBJECT | INTERFACE

"""
Indicates how clients should handle errors on a given position.
When used on the schema definition, `@catch` applies to every position that can return an error.
The `level` argument indicates where to catch errors in case of lists:
The `levels` argument indicates where to catch errors in case of lists:
```graphql
{
user {
# friends catches errors
friends @catch { name } # same as @catch(level:0)
friends @catch { name } # same as @catch(levels: [0])
# every friends[k] catches errors
friends @catch(level: 0) { name }
friends @catch(levels: [0]) { name }
# friends as well as every friends[k] catches errors
friends @catch(level: 0) @catch(level: 1) { name }
friends @catch(levels: [0, 1]) { name }
}
}
```
`level` is zero indexed.
`levels` are zero indexed.
Passing a negative level or a level greater than the list dimension is an error.
See `CatchTo` for more details.
"""
directive @catch(to: CatchTo! = RESULT, level: Int = 0) repeatable on FIELD | SCHEMA
directive @catch(to: CatchTo! = RESULT, levels: [Int] = [0]) on FIELD | SCHEMA

enum CatchTo {
"""
Expand Down

0 comments on commit 8bfa87e

Please sign in to comment.