input_object.ex (1565B)
1 defmodule Absinthe.Type.InputObject do 2 @moduledoc """ 3 Defines a GraphQL input object 4 5 Input objects enable nested arguments to queries and mutations. 6 7 ## Example 8 9 ``` 10 mutation do 11 field :user, :user do 12 arg :name, :string 13 arg :contact, non_null(:contact) 14 15 resolve &User.create/2 16 end 17 end 18 19 input_object :contact do 20 field :email, :string 21 end 22 ``` 23 24 This supports the following `mutation`: 25 ```graphql 26 mutation CreateUser { 27 user(contact: {email: "foo@bar.com"}) { 28 id 29 } 30 } 31 ``` 32 """ 33 34 use Absinthe.Introspection.TypeKind, :input_object 35 use Absinthe.Type.Fetch 36 37 alias Absinthe.Type 38 39 @typedoc """ 40 Note new input object types should be defined using 41 `Absinthe.Schema.Notation.input_object/3`. 42 43 * `:name` - The name of the input object type. Should be a TitleCased `binary`. Set automatically. 44 * `:description` - A nice description for introspection. 45 * `:fields` - A map of `Absinthe.Type.Field` structs. Usually built via `Absinthe.Schema.Notation.field/4`. 46 47 The `__private__` and `:__reference__` fields are for internal use. 48 """ 49 @type t :: %__MODULE__{ 50 name: binary, 51 description: binary, 52 fields: map, 53 identifier: atom, 54 __private__: Keyword.t(), 55 definition: module, 56 __reference__: Type.Reference.t() 57 } 58 59 defstruct name: nil, 60 description: nil, 61 fields: %{}, 62 identifier: nil, 63 __private__: [], 64 definition: nil, 65 __reference__: nil 66 end