lib/graphql/schema/argument.rb in graphql-1.12.24 vs lib/graphql/schema/argument.rb in graphql-1.13.0
- old
+ new
@@ -1,13 +1,9 @@
# frozen_string_literal: true
module GraphQL
class Schema
class Argument
- if !String.method_defined?(:-@)
- using GraphQL::StringDedupBackport
- end
-
include GraphQL::Schema::Member::CachedGraphQLDefinition
include GraphQL::Schema::Member::AcceptsDefinition
include GraphQL::Schema::Member::HasPath
include GraphQL::Schema::Member::HasAstNode
include GraphQL::Schema::Member::HasDirectives
@@ -50,11 +46,11 @@
# @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.
# @param directives [Hash{Class => Hash}]
# @param deprecation_reason [String]
# @param validates [Hash, nil] Options for building validators, if any should be applied
- 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:, validates: nil, directives: nil, deprecation_reason: nil, &definition_block)
+ def initialize(arg_name = nil, type_expr = nil, desc = nil, required: true, 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:, validates: nil, directives: nil, deprecation_reason: nil, &definition_block)
arg_name ||= name
@name = -(camelize ? Member::BuildType.camelize(arg_name.to_s) : arg_name.to_s)
@type_expr = type_expr || type
@description = desc || description
@null = !required
@@ -84,10 +80,14 @@
instance_eval(&definition_block)
end
end
end
+ def inspect
+ "#<#{self.class} #{path}: #{type.to_type_signature}#{description ? " @description=#{description.inspect}" : ""}>"
+ end
+
# @return [Object] the value used when the client doesn't provide a value for this argument
attr_reader :default_value
# @return [Boolean] True if this argument has a default value
def default_value?
@@ -145,10 +145,10 @@
if !authorized_as_type?(obj, v, ctx, as_type: as_type.of_type)
return false
end
end
elsif as_type.kind.input_object?
- as_type.arguments.each do |_name, input_obj_arg|
+ as_type.arguments(ctx).each do |_name, input_obj_arg|
input_obj_arg = input_obj_arg.type_class
# TODO: this skips input objects whose values were alread replaced with application objects.
# See: https://github.com/rmosolgo/graphql-ruby/issues/2633
if value.is_a?(InputObject) && value.key?(input_obj_arg.keyword) && !input_obj_arg.authorized?(obj, value[input_obj_arg.keyword], ctx)
return false