File tree Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ module Define
19
19
# # After definition, read the key from metadata
20
20
# PostType.metadata[:resolves_to_class_names] # => [...]
21
21
#
22
- # @param [Object] the key to assign in metadata
22
+ # @param key [Object] the key to assign in metadata
23
23
# @return [#call(defn, value)] an assignment for `.accepts_definitions` which writes `key` to `#metadata`
24
24
def self . assign_metadata_key ( key )
25
25
GraphQL ::Define ::InstanceDefinable ::AssignMetadataKey . new ( key )
Original file line number Diff line number Diff line change @@ -72,6 +72,16 @@ module GraphQL
72
72
# }
73
73
# end
74
74
#
75
+ # Only certain types maybe used for inputs:
76
+ #
77
+ # - Scalars
78
+ # - Enums
79
+ # - Input Objects
80
+ # - Lists of those types
81
+ #
82
+ # Input types may also be non-null -- in that case, the query will fail
83
+ # if the input is not present.
84
+ #
75
85
# ## Complexity
76
86
#
77
87
# Fields can have _complexity_ values which describe the computation cost of resolving the field.
Original file line number Diff line number Diff line change 1
1
module GraphQL
2
- # A complex input type for a field argument.
2
+ # {InputObjectType}s are key-value inputs for fields.
3
+ #
4
+ # Input objects have _arguments_ which are identical to {GraphQL::Field} arguments.
5
+ # They map names to types and support default values.
6
+ # Their input types can be any input types, including {InputObjectType}s.
3
7
#
4
8
# @example An input type with name and number
5
9
# PlayerInput = GraphQL::InputObjectType.define do
6
10
# name("Player")
7
- # input_field :name, !types.String
8
- # input_field :number, !types.Int
11
+ # argument :name, !types.String
12
+ # argument :number, !types.Int
9
13
# end
10
14
#
15
+ # In a `resolve` function, you can access the values by making nested lookups on `args`.
16
+ #
17
+ # @example Accessing input values in a resolve function
18
+ # resolve -> (obj, args, ctx) {
19
+ # args[:player][:name] # => "Tony Gwynn"
20
+ # args[:player][:number] # => 19
21
+ # args[:player].to_h # { "name" => "Tony Gwynn", "number" => 19 }
22
+ # # ...
23
+ # }
24
+ #
11
25
class InputObjectType < GraphQL ::BaseType
12
26
accepts_definitions (
13
27
input_field : GraphQL ::Define ::AssignArgument ,
You can’t perform that action at this time.
0 commit comments