Module: GraphQL::Schema::HasSingleInputArgument::ClassMethods
- Defined in:
- lib/graphql/schema/has_single_input_argument.rb
Overview
-- @requires_ancestor: singleton(GraphQL::Schema::Resolver)
Instance Method Summary collapse
- #all_field_argument_definitions ⇒ Object
- #any_field_arguments? ⇒ Boolean
-
#argument(*args, own_argument: false, **kwargs, &block) ⇒ Object
Also apply this argument to the input type:.
- #dummy ⇒ Object
- #field_arguments(context = GraphQL::Query::NullContext.instance) ⇒ Object
- #get_field_argument(name, context = GraphQL::Query::NullContext.instance) ⇒ Object
-
#input_object_class(new_class = nil) ⇒ Object
The base class for generated input object types.
-
#input_type(new_input_type = nil) ⇒ Object
Parameters.
- #own_field_arguments ⇒ Object
Instance Method Details
#all_field_argument_definitions ⇒ Object
92 93 94 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 92 def all_field_argument_definitions dummy.all_argument_definitions end |
#any_field_arguments? ⇒ Boolean
88 89 90 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 88 def any_field_arguments? dummy.any_arguments? end |
#argument(*args, own_argument: false, **kwargs, &block) ⇒ Object
Also apply this argument to the input type:
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 97 def argument(*args, own_argument: false, **kwargs, &block) it = input_type # make sure any inherited arguments are already added to it args = args #: untyped arg = super(*args, **kwargs, &block) # This definition might be overriding something inherited; # if it is, remove the inherited definition so it's not confused at runtime as having multiple definitions prev_args = it.own_arguments[arg.graphql_name] case prev_args when GraphQL::Schema::Argument if prev_args.owner != self it.own_arguments.delete(arg.graphql_name) end when Array prev_args.reject! { |a| a.owner != self } if prev_args.empty? it.own_arguments.delete(arg.graphql_name) end end it.add_argument(arg) arg end |
#dummy ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 65 def dummy @dummy ||= begin d = Class.new(GraphQL::Schema::Resolver) d.graphql_name "#{self.graphql_name}DummyResolver" d.argument_class(self.argument_class) # TODO make this lazier? d.argument(:input, input_type, description: "Parameters for #{self.graphql_name}") d end end |
#field_arguments(context = GraphQL::Query::NullContext.instance) ⇒ Object
76 77 78 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 76 def field_arguments(context = GraphQL::Query::NullContext.instance) dummy.arguments(context) end |
#get_field_argument(name, context = GraphQL::Query::NullContext.instance) ⇒ Object
80 81 82 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 80 def get_field_argument(name, context = GraphQL::Query::NullContext.instance) dummy.get_argument(name, context) end |
#input_object_class(new_class = nil) ⇒ Object
The base class for generated input object types
Parameters
new_class(Class) — The base class to use for generating input object definitions
Returns
Class— The base class for this mutation's generated input object (default is GraphQL::Schema::InputObject)
:call-seq:
input_object_class(Class new_class) -> Class
133 134 135 136 137 138 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 133 def input_object_class(new_class = nil) if new_class @input_object_class = new_class end @input_object_class || (superclass.respond_to?(:input_object_class) ? superclass.input_object_class : GraphQL::Schema::InputObject) end |
#input_type(new_input_type = nil) ⇒ Object
Parameters
new_input_type(Class, nil) — If provided, it configures this mutation to acceptnew_input_typeinstead of generating an input type
Returns
Class— The generated Schema::InputObject class for this mutation'sinput
:call-seq:
input_type(Class | nil new_input_type) -> Class
150 151 152 153 154 155 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 150 def input_type(new_input_type = nil) if new_input_type @input_type = new_input_type end @input_type ||= generate_input_type end |
#own_field_arguments ⇒ Object
84 85 86 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 84 def own_field_arguments dummy.own_arguments end |