-
Notifications
You must be signed in to change notification settings - Fork 6
Add nullability directives #36
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9aa8b03
Add nullability directives
martinbonnin cd8afbd
fixes from https://github.com/apollographql/apollo-kotlin/pull/5405
martinbonnin 10ae7f8
remove `if`
martinbonnin ccbbd76
nullOnlyOnErrors -> semanticNonNull
martinbonnin 629fa84
wording
martinbonnin 6f3580e
add description to CatchTo enum values
martinbonnin 646a552
Update nullability/v0.1/nullability-v0.1.graphql
martinbonnin 0c610d2
Add CatchTo.THROW
martinbonnin 9f1795c
add comments
martinbonnin f45d4a7
Merge branch 'main' into nullability
martinbonnin 7a1b234
Update nullability/v0.1/nullability-v0.1.md
martinbonnin 2393992
only keep the latest version in the table of contents
martinbonnin 639ab1f
wording
martinbonnin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| """ | ||
| Indicates that a field is only null if there is a matching error in the `errors` array. | ||
| In all other cases, the field is non-null. | ||
|
|
||
| Tools doing code generation may use this information to generate the field as non-null. | ||
|
|
||
| This directive can be applied on field definitions: | ||
|
|
||
| ```graphql | ||
| type User { | ||
| email: String @semanticNonNull | ||
| } | ||
| ``` | ||
|
|
||
| It can also be applied on object type extensions for use in client applications that do | ||
| not own the base schema: | ||
|
|
||
| ```graphql | ||
| extend type User @semanticNonNull(field: "email") | ||
| ``` | ||
|
|
||
| Control over list items is done using the `level` argument: | ||
|
|
||
| ```graphql | ||
| type User { | ||
| # friends is nullable but friends[0] is null only on errors | ||
| friends: [User] @semanticNonNull(level: 1) | ||
| } | ||
| ``` | ||
|
|
||
| @param field the name of the field if applied to an object definition or null if applied | ||
| to a field definition | ||
|
|
||
| @param level in case of a list type, level is the dimension where to apply the modifier, | ||
| starting at 0 if there is no list. | ||
| If level is null, the modifier is applied to all levels | ||
| """ | ||
| directive @semanticNonNull(field: String = null, level: Int = null) repeatable on FIELD_DEFINITION | OBJECT | ||
|
|
||
| """ | ||
| Indicates that a field acts as an error boundary in case of a GraphQL error. | ||
|
|
||
| By default, the first GraphQL error throws and fails the whole response. | ||
|
|
||
| @param level in case of a list type, level is the dimension where to apply the modifier, | ||
| starting at 0 if there is no list. | ||
| If level is null, the modifier is applied to all levels | ||
| """ | ||
| directive @catch(to: CatchTo! = RESULT, level: Int = null) repeatable on FIELD | ||
|
|
||
| enum CatchTo { | ||
| NULL, | ||
| RESULT, | ||
BoD marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| """ | ||
| Never throw on errors. | ||
|
|
||
| This is used for backward compatibility for clients where this was the default behaviour. | ||
| """ | ||
| directive @ignoreErrors on QUERY | MUTATION | SUBSCRIPTION | ||
BoD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # nullability v0.1 | ||
|
|
||
| <h2>Experimental nullability directives</h2> | ||
|
|
||
| ```raw html | ||
| <table class=spec-data> | ||
| <tr><td>Status</td><td>Release</td> | ||
| <tr><td>Version</td><td>0.1</td> | ||
| </table> | ||
| <link rel=stylesheet href=https://specs.apollo.dev/apollo-light.css> | ||
| <script type=module async defer src=https://specs.apollo.dev/inject-logo.js></script> | ||
| ``` | ||
|
|
||
| This specification provides a list of directives to help dealing with nullability. For more information, see [the nullability working group GitHub](https://github.com/graphql/nullability-wg) | ||
|
|
||
|
|
||
| #! @semanticNonNull | ||
|
|
||
| :::[definition](nullability-v0.1.graphql#@semanticNonNull) | ||
|
|
||
| #! @catch | ||
|
|
||
| :::[definition](nullability-v0.1.graphql#@catch) |
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.
Uh oh!
There was an error while loading. Please reload this page.