Class: GraphQL::InputObjectType
- Extended by:
- Define::InstanceDefinable::DeprecatedDefine
- Defined in:
- lib/graphql/input_object_type.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Hash<String => GraphQL::Argument>
(also: #input_fields)
Map String argument names to their Argument implementations.
-
#arguments_class ⇒ Object
-
#mutation ⇒ GraphQL::Relay::Mutation?
The mutation this field was derived from, if it was derived from a mutation.
Attributes inherited from BaseType
#ast_node, #default_relay, #default_scalar, #description, #introspection, #name
Instance Method Summary collapse
-
#coerce_result(value, ctx = nil) ⇒ Object
-
#get_argument(argument_name) ⇒ Object
-
#initialize ⇒ InputObjectType
constructor
A new instance of InputObjectType.
-
#initialize_copy(other) ⇒ Object
-
#kind ⇒ Object
Methods included from Define::InstanceDefinable::DeprecatedDefine
Methods inherited from BaseType
#==, #coerce_input, #coerce_isolated_input, #coerce_isolated_result, #default_relay?, #default_scalar?, #get_field, #introspection?, #list?, #non_null?, resolve_related_type, #resolve_type, #to_definition, #to_list_type, #to_non_null_type, #to_s, #type_class, #unwrap, #valid_input?, #valid_isolated_input?, #validate_input, #validate_isolated_input
Methods included from Relay::TypeExtensions
#connection_type, #define_connection, #define_edge, #edge_type
Methods included from Define::InstanceDefinable
#define, #deprecated_define, #metadata, #redefine
Methods included from Define::NonNullWithBang
Constructor Details
#initialize ⇒ InputObjectType
Returns a new instance of InputObjectType.
24 25 26 27 |
# File 'lib/graphql/input_object_type.rb', line 24 def initialize super @arguments = {} end |
Instance Attribute Details
#arguments ⇒ Hash<String => GraphQL::Argument> Also known as: input_fields
Returns Map String argument names to their Argument implementations.
20 21 22 |
# File 'lib/graphql/input_object_type.rb', line 20 def arguments @arguments end |
#arguments_class ⇒ Object
13 14 15 |
# File 'lib/graphql/input_object_type.rb', line 13 def arguments_class @arguments_class end |
#mutation ⇒ GraphQL::Relay::Mutation?
Returns The mutation this field was derived from, if it was derived from a mutation.
17 18 19 |
# File 'lib/graphql/input_object_type.rb', line 17 def mutation @mutation end |
Instance Method Details
#coerce_result(value, ctx = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/graphql/input_object_type.rb', line 38 def coerce_result(value, ctx = nil) if ctx.nil? warn_deprecated_coerce("coerce_isolated_result") ctx = GraphQL::Query::NullContext end # Allow the application to provide values as :symbols, and convert them to the strings value = value.reduce({}) { |memo, (k, v)| memo[k.to_s] = v; memo } result = {} arguments.each do |input_key, input_field_defn| input_value = value[input_key] if value.key?(input_key) result[input_key] = if input_value.nil? nil else input_field_defn.type.coerce_result(input_value, ctx) end end end result end |
#get_argument(argument_name) ⇒ Object
63 64 65 |
# File 'lib/graphql/input_object_type.rb', line 63 def get_argument(argument_name) arguments[argument_name] end |
#initialize_copy(other) ⇒ Object
29 30 31 32 |
# File 'lib/graphql/input_object_type.rb', line 29 def initialize_copy(other) super @arguments = other.arguments.dup end |