Modifiers

Modifiers are like built-in generic types that will modify the provided type based on some rules. Users cannot define their own modifiers, only use the built-in ones.

These are the currently available modifiers:

Optional

The Optional modifier takes a type or an input as a parameter and outputs a similar object with all its fields marked as "nullable". If the field in the original object was declared required with a ! the output will contain that field without the !, otherwise the field is left untouched.

Open in sandbox

Source GraphQXL Compiled GraphQL
type _SomeType {
    foo: String!
    bar: Int!
    bool: [Float!]
}

type OptionalType = Optional<_SomeType>
type OptionalType {
    foo: String
    bar: Int
    bool: [Float!]
}


Required

The Required modifier takes a type or an input as a parameter and outputs a similar object with all its fields marked as "non-nullable". If a field in the original object did not have a !, it will have it in the new object, otherwise it will be left untouched

Open in sandbox

Source GraphQXL Compiled GraphQL
type _SomeType {
    foo: String
    bar: Int
    bool: [Float]!
}

type RequiredType = Required<_SomeType>
type RequiredType {
    foo: String!
    bar: Int!
    bool: [Float]!
}