non_null.ex (893B)
1 defmodule Absinthe.Type.NonNull do 2 @moduledoc """ 3 A type that wraps an underlying type, acting identically to that type but 4 adding a non-null constraint. 5 6 By default, all types in GraphQL are nullable. To declare a type that 7 disallows null, wrap it in a `Absinthe.Type.NonNull` struct. 8 9 ## Examples 10 11 Given a type, `:item`, to declare it as non-null, you could do the following: 12 13 ``` 14 type: %Absinthe.Type.NonNull{of_type: :item} 15 ``` 16 17 But normally this would be done using `Absinthe.Schema.Notation.non_null/1`. 18 19 ``` 20 type: non_null(:item) 21 ``` 22 """ 23 24 use Absinthe.Introspection.TypeKind, :non_null 25 use Absinthe.Type.Fetch 26 27 @typedoc """ 28 A defined non-null type. 29 30 ## Options 31 32 * `:of_type` -- the underlying type to wrap 33 """ 34 defstruct of_type: nil 35 36 @type t :: %__MODULE__{of_type: Absinthe.Type.nullable_t()} 37 @type t(x) :: %__MODULE__{of_type: x} 38 end