graphql-ruby
graphql-ruby copied to clipboard
Redefined function arguments do not apply changes when subclassing
When you subclass a custom function, the arguments function seems to merge in the incorrect direction which causes overridden arguments to be ignored. https://github.com/rmosolgo/graphql-ruby/blob/master/lib/graphql/function.rb#L73
require 'graphql'
TestInput = GraphQL::InputObjectType.define do
name 'Test'
argument :id, !types.ID
end
RedefinedTestInput = TestInput.redefine do
name 'RedefinedTest'
argument :name, !types.String
end
class TestFunc < GraphQL::Function
argument :thing, !TestInput
end
class SubclassedTestFunc < TestFunc
argument :thing, !RedefinedTestInput
end
puts TestFunc.arguments["thing"].inspect #=> Test!
puts SubclassedTestFunc.arguments["thing"].inspect #=> Test!
puts SubclassedTestFunc.send(:own_arguments)["thing"].inspect #=> RedefinedTest!
Is this the intended behavior?
No, this isn't the intended behavior! Looks like a mess-up on my part and a lack of test coverage 😖
Thanks for the great write-up, by the way.
Sorry for the hangup here, I think GraphQL::Schema::Resolver will work for this.