Skip to content

Commit 1d72531

Browse files
authored
Merge pull request #5372 from rmosolgo/better-interface-error
Improve errors and handling of interfaces from SDL
2 parents 0fff1e2 + 318f97a commit 1d72531

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/graphql/schema/build_from_definition.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ def build(schema_superclass, document, default_resolve:, using: {}, base_types:
187187

188188
object_types.each do |t|
189189
t.interfaces.each do |int_t|
190+
if int_t.is_a?(LateBoundType)
191+
int_t = types[int_t.graphql_name]
192+
t.implements(int_t)
193+
end
190194
int_t.orphan_types(t)
191195
end
192196
end

lib/graphql/schema/member/has_interfaces.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ def implements(*new_interfaces, **options)
88
new_memberships = []
99
new_interfaces.each do |int|
1010
if int.is_a?(Module)
11-
unless int.include?(GraphQL::Schema::Interface)
12-
raise "#{int} cannot be implemented since it's not a GraphQL Interface. Use `include` for plain Ruby modules."
11+
unless int.include?(GraphQL::Schema::Interface) && !int.is_a?(Class)
12+
raise "#{int.respond_to?(:graphql_name) ? "#{int.graphql_name} (#{int})" : int.inspect} cannot be implemented since it's not a GraphQL Interface. Use `include` for plain Ruby modules."
1313
end
1414

1515
new_memberships << int.type_membership_class.new(int, self, **options)

0 commit comments

Comments
 (0)