Remove override of prepare on input objects
What does this MR do and why?
This MR prevents #prepare
from returning a different object type so we move the
overrides to #to_h
.
In GraphQL 2.2.6, this caused problems because of https://github.com/rmosolgo/graphql-ruby/pull/4804. GraphQL now iterates over lists of input objects and expects them to be input objects.
Previously, the code for lists had .select { |value| value.respond_to?(:arguments) }
. But now, it does:
when TypeKinds::INPUT_OBJECT
argument.value.each do |value|
extract_deprecated_arguments(value.arguments.argument_values) # rubocop:disable Development/ContextIsPassedCop -- runtime args instance
end
So when the argument is declared as an INPUT_OBJECT
, it is expected to respond to #arguments
.
This is extracted from !146295 (merged).
Example failure: https://gitlab.com/gitlab-org/gitlab/-/jobs/6288576329
Internal server error: undefined method `arguments' for {:name=>\"code\", :custom=>true}:hash:
/builds/gitlab-org/gitlab/vendor/ruby/3.1.0/gems/graphql-2.2.10/lib/graphql/analysis/ast/field_usage.rb:60:in `block (2 levels) in extract_deprecated_arguments'
/builds/gitlab-org/gitlab/vendor/ruby/3.1.0/gems/graphql-2.2.10/lib/graphql/analysis/ast/field_usage.rb:59:in `each'
/builds/gitlab-org/gitlab/vendor/ruby/3.1.0/gems/graphql-2.2.10/lib/graphql/analysis/ast/field_usage.rb:59:in `block in extract_deprecated_arguments'
/builds/gitlab-org/gitlab/vendor/ruby/3.1.0/gems/graphql-2.2.10/lib/graphql/analysis/ast/field_usage.rb:39:in `each_pair'
/builds/gitlab-org/gitlab/vendor/ruby/3.1.0/gems/graphql-2.2.10/lib/graphql/analysis/ast/field_usage.rb:39:in `extract_deprecated_arguments'
/builds/gitlab-org/gitlab/vendor/ruby/3.1.0/gems/graphql-2.2.10/lib/graphql/analysis/ast/field_usage.rb:52:in `block in extract_deprecated_arguments'
/builds/gitlab-org/gitlab/vendor/ruby/3.1.0/gems/graphql-2.2.10/lib/graphql/analysis/ast/field_usage.rb:39:in `each_pair'
/builds/gitlab-org/gitlab/vendor/ruby/3.1.0/gems/graphql-2.2.10/lib/graphql/analysis/ast/field_usage.rb:39:in `extract_deprecated_arguments'
/builds/gitlab-org/gitlab/vendor/ruby/3.1.0/gems/graphql-2.2.10/lib/graphql/analysis/ast/field_usage.rb:23:in `on_leave_field'
/builds/gitlab-org/gitlab/vendor/ruby/3.1.0/gems/graphql-2.2.10/lib/graphql/analysis/ast/visitor.rb:85:in `block in call_on_leave_field'
/builds/gitlab-org/gitlab/vendor/ruby/3.1.0/gems/graphql-2.2.10/lib/graphql/analysis/ast/visitor.rb:83:in `each'
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.