lib/graphql/schema/argument.rb in graphql-1.9.7 vs lib/graphql/schema/argument.rb in graphql-1.9.8
- old
+ new
@@ -22,20 +22,27 @@
attr_reader :keyword
# @return [Class, Module, nil] If this argument should load an application object, this is the type of object to load
attr_reader :loads
+ # @return [Boolean] true if a resolver defined this argument
+ def from_resolver?
+ @from_resolver
+ end
+
# @param arg_name [Symbol]
# @param type_expr
# @param desc [String]
# @param required [Boolean] if true, this argument is non-null; if false, this argument is nullable
# @param description [String]
# @param default_value [Object]
# @param as [Symbol] Override the keyword name when passed to a method
# @param prepare [Symbol] A method to call to transform this argument's valuebefore sending it to field resolution
# @param camelize [Boolean] if true, the name will be camelized when building the schema
- def initialize(arg_name = nil, type_expr = nil, desc = nil, required:, type: nil, name: nil, loads: nil, description: nil, default_value: NO_DEFAULT, as: nil, camelize: true, prepare: nil, owner:, &definition_block)
+ # @param from_resolver [Boolean] if true, a Resolver class defined this argument
+ # @param method_access [Boolean] If false, don't build method access on legacy {Query::Arguments} instances.
+ def initialize(arg_name = nil, type_expr = nil, desc = nil, required:, type: nil, name: nil, loads: nil, description: nil, ast_node: nil, default_value: NO_DEFAULT, as: nil, from_resolver: false, camelize: true, prepare: nil, method_access: true, owner:, &definition_block)
arg_name ||= name
name_str = camelize ? Member::BuildType.camelize(arg_name.to_s) : arg_name.to_s
@name = name_str.freeze
@type_expr = type_expr || type
@description = desc || description
@@ -44,10 +51,13 @@
@owner = owner
@as = as
@loads = loads
@keyword = as || Schema::Member::BuildType.underscore(@name).to_sym
@prepare = prepare
+ @ast_node = ast_node
+ @from_resolver = from_resolver
+ @method_access = method_access
if definition_block
if definition_block.arity == 1
instance_exec(self, &definition_block)
else
@@ -92,9 +102,10 @@
argument.name = @name
argument.type = -> { type }
argument.description = @description
argument.metadata[:type_class] = self
argument.as = @as
+ argument.method_access = @method_access
if NO_DEFAULT != @default_value
argument.default_value = @default_value
end
argument
end