Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/graphql/schema/interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def included(child_class)
end

child_class.ancestors.reverse_each do |ancestor|
if ancestor.const_defined?(:ResolverMethods)
if ancestor != child_class && ancestor <= GraphQL::Schema::Interface && ancestor.const_defined?(:ResolverMethods, false)
child_class.extend(ancestor::ResolverMethods)
end
end
Expand Down
35 changes: 35 additions & 0 deletions spec/graphql/schema/interface_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,41 @@ module InterfaceE
end
end

describe "::ResolverMethods" do
it "doesn't conflict with a top-level module" do
Object.const_set(:ResolverMethods, Module.new do
def not_a_resolver
end
end)
new_int = Module.new do
include GraphQL::Schema::Interface
resolver_methods do
def resolver_test
end
end
end

other_new_int = Module.new do
include GraphQL::Schema::Interface
resolver_methods do
def resolver_test_2
end
end
end

new_object = Class.new(GraphQL::Schema::Object) do
implements new_int
implements other_new_int
end

assert new_object.respond_to?(:resolver_test)
assert new_object.respond_to?(:resolver_test_2)
refute new_object.respond_to?(:not_a_resolver)
ensure
Object.send :remove_const, :ResolverMethods
end
end

describe "comments" do
class SchemaWithInterface < GraphQL::Schema
module InterfaceWithComment
Expand Down
Loading