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
73 74 75 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 73 def all_field_argument_definitions dummy.all_argument_definitions end |
#any_field_arguments? ⇒ Boolean
69 70 71 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 69 def any_field_arguments? dummy.any_arguments? end |
#argument(*args, own_argument: false, **kwargs, &block) ⇒ Object
Also apply this argument to the input type:
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 78 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
47 48 49 50 51 52 53 54 55 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 47 def dummy @dummy ||= begin d = Class.new(GraphQL::Schema::Resolver) 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
57 58 59 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 57 def field_arguments(context = GraphQL::Query::NullContext.instance) dummy.arguments(context) end |
#get_field_argument(name, context = GraphQL::Query::NullContext.instance) ⇒ Object
61 62 63 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 61 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
104 105 106 107 108 109 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 104 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
.
113 114 115 116 117 118 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 113 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
65 66 67 |
# File 'lib/graphql/schema/has_single_input_argument.rb', line 65 def own_field_arguments dummy.own_arguments end |