|
| 1 | +""" |
| 2 | +Indicates that a field is only null if there is a matching error in the `errors` array. |
| 3 | +In all other cases, the field is non-null. |
| 4 | +
|
| 5 | +Tools doing code generation may use this information to generate the field as non-null. |
| 6 | +
|
| 7 | +This directive can be applied on field definitions: |
| 8 | +
|
| 9 | +```graphql |
| 10 | +type User { |
| 11 | + email: String @semanticNonNull |
| 12 | +} |
| 13 | +``` |
| 14 | +
|
| 15 | +It can also be applied on object type extensions for use in client applications that do |
| 16 | +not own the base schema: |
| 17 | +
|
| 18 | +```graphql |
| 19 | +extend type User @semanticNonNull(field: "email") |
| 20 | +``` |
| 21 | +
|
| 22 | +Control over list items is done using the `level` argument: |
| 23 | +
|
| 24 | +```graphql |
| 25 | +type User { |
| 26 | + # friends is nullable but friends[0] is null only on errors |
| 27 | + friends: [User] @semanticNonNull(level: 1) |
| 28 | +} |
| 29 | +``` |
| 30 | +
|
| 31 | +The `field` argument is the name of the field if `@semanticNonNull` is applied to an object definition. |
| 32 | +If `@semanticNonNull` is applied to a field definition, `field` must be null. |
| 33 | +
|
| 34 | +The `level` argument can be used to indicate what level is semantically non null in case of lists. |
| 35 | +`level` starts at 0 if there is no list. If `level` is null, all levels are semantically non null. |
| 36 | +""" |
| 37 | +directive @semanticNonNull(field: String = null, level: Int = null) repeatable on FIELD_DEFINITION | OBJECT |
| 38 | + |
| 39 | +""" |
| 40 | +Indicates how clients should handle errors on a given position. |
| 41 | +
|
| 42 | +When used on the schema definition, `@catch` applies to every position that can return an error. |
| 43 | +
|
| 44 | +The `level` argument can be used to indicate where to catch in case of lists. |
| 45 | +`level` starts at 0 if there is no list. If `level` is null, all levels catch. |
| 46 | +
|
| 47 | +See `CatchTo` for more details. |
| 48 | +""" |
| 49 | +directive @catch(to: CatchTo! = RESULT, level: Int = null) repeatable on FIELD | SCHEMA |
| 50 | + |
| 51 | +enum CatchTo { |
| 52 | + """ |
| 53 | + Catch the error and map the position to a result type that can contain either |
| 54 | + a value or an error. |
| 55 | + """ |
| 56 | + RESULT, |
| 57 | + """ |
| 58 | + Catch the error and map the position to a nullable type that will be null |
| 59 | + in the case of error. |
| 60 | + This does not allow to distinguish between semantic null and error null but |
| 61 | + can be simpler in some cases. |
| 62 | + """ |
| 63 | + NULL, |
| 64 | + """ |
| 65 | + Throw the error. |
| 66 | + Parent fields can recover using `RESULT` or `NULL`. |
| 67 | + If no parent field recovers, the parsing stops. |
| 68 | + """ |
| 69 | + THROW |
| 70 | +} |
| 71 | + |
| 72 | +""" |
| 73 | +Never throw on field errors. |
| 74 | +
|
| 75 | +This is used for backward compatibility for clients where this was the default behaviour. |
| 76 | +""" |
| 77 | +directive @ignoreErrors on QUERY | MUTATION | SUBSCRIPTION |
0 commit comments