Skip to content
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

Add nullability directives #36

Merged
merged 13 commits into from
Dec 11, 2023
Merged

Add nullability directives #36

merged 13 commits into from
Dec 11, 2023

Conversation

martinbonnin
Copy link
Contributor

@martinbonnin martinbonnin commented Nov 27, 2023

Introduce 2 directives used to help working with nullability.

@semanticNonNull

type User {
    # generate email as non-null String in Kotlin even though its type is nullable
    email: String @semanticNonNull
}

@semanticNonNull is the third state found in proposals such as SemanticNonNull except it adds no new GraphQL syntax.

@semanticNonNull can be used in the server schema but also as client extensions:

extend type User @semanticNonNull(field: "email")

@catch

{
  # generate user as `FieldResult<String, Error>` in Kotlin to have access to the error if needed
  user @catch(to: RESULT) {
    name
  }
}

@catch can also be used to fail the whole response in case there is an error in one field:

{
  # fail the response if user or name has an associated error
  user @catch(to: THROW) {
    name
  }
}

Copy link
Contributor

@BoD BoD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hwillson hwillson self-requested a review December 8, 2023 19:28
Copy link
Member

@hwillson hwillson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @martinbonnin - thanks for working on this!

@martinbonnin martinbonnin merged commit ec27a72 into main Dec 11, 2023
6 checks passed
@martinbonnin martinbonnin deleted the nullability branch December 11, 2023 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants