Skip to main content

Minimum requirements

PackageMinimum version
composition0.45.0
wgc0.93.1

Definition

directive @semanticNonNull(levels: [Int!]! = [0]) on FIELD_DEFINITION

Overview

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. Tools doing code generation may use this information to generate the position as non-null if field errors are handled out of band:
type User {
    # email is semantically non-null and can be generated as non-null by error-handling clients.
    email: String @semanticNonNull
}

Using with Lists

The levels argument indicates what levels are semantically non null in case of lists:
type User {
    # friends is semantically non null
    friends: [User] @semanticNonNull # same as @semanticNonNull(levels: [0])
    
    # every friends[k] is semantically non null
    friends: [User] @semanticNonNull(levels: [1])
    
    # friends as well as every friends[k] is semantically non null
    friends: [User] @semanticNonNull(levels: [0, 1])
}
levels are zero indexed. Passing a negative level or a level greater than the list dimension is an error.