Module: GraphQL::Schema::HasSingleInputArgument::ClassMethods
- Defined in:
- lib/graphql/schema/has_single_input_argument.rb
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) ⇒ Class
The base class for generated input object types.
-
#input_type(new_input_type = nil) ⇒ Class
The generated InputObject class for this mutation's
input. - #own_field_arguments ⇒ Object
Instance Method Details
#all_field_argument_definitions ⇒ Object
85 86 87 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 85 def all_field_argument_definitions dummy.all_argument_definitions end |
#any_field_arguments? ⇒ Boolean
81 82 83 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 81 def any_field_arguments? dummy.any_arguments? end |
#argument(*args, own_argument: false, **kwargs, &block) ⇒ Object
Also apply this argument to the input type:
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 90 def argument(*args, own_argument: false, **kwargs, &block) it = input_type # make sure any inherited arguments are already added to it 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
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 58 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
69 70 71 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 69 def field_arguments(context = GraphQL::Query::NullContext.instance) dummy.arguments(context) end |
#get_field_argument(name, context = GraphQL::Query::NullContext.instance) ⇒ Object
73 74 75 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 73 def get_field_argument(name, context = GraphQL::Query::NullContext.instance) dummy.get_argument(name, context) end |
#input_object_class(new_class = nil) ⇒ Class
The base class for generated input object types
116 117 118 119 120 121 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 116 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) ⇒ Class
Returns The generated InputObject class for this mutation's input.
125 126 127 128 129 130 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 125 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
77 78 79 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 77 def own_field_arguments dummy.own_arguments end |