Skip to content

Commit f8e879f

Browse files
committed
Update some tests and update schema building code
1 parent f1d4266 commit f8e879f

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

lib/graphql/schema/build_from_definition.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,13 @@ def build(schema_superclass, document, default_resolve:, using: {}, relay:)
120120

121121
builder = self
122122

123+
found_types = types.values
124+
object_types = found_types.select { |t| t.kind.object? }
123125
schema_class = Class.new(schema_superclass) do
124126
begin
125127
# Add these first so that there's some chance of resolving late-bound types
126-
orphan_types types.values
128+
add_type_and_traverse(found_types, root: false)
129+
orphan_types(object_types)
127130
query query_root_type
128131
mutation mutation_root_type
129132
subscription subscription_root_type

lib/graphql/schema/loader.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def load(introspection_result)
3232
end
3333

3434
Class.new(GraphQL::Schema) do
35-
orphan_types(types.values)
35+
add_type_and_traverse(types.values, root: false)
36+
orphan_types(types.values.select { |t| t.kind.object? })
3637
directives(directives)
3738
description(schema["description"])
3839

spec/graphql/schema/dynamic_members_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ class Mutation < BaseObject
360360

361361
query(Query)
362362
mutation(Mutation)
363-
orphan_types(Place, LegacyPlace, Locale, Region, Country)
363+
orphan_types(Place, LegacyPlace, Country)
364364
end
365365

366366
def check_for_multiple_visible_calls(context)
@@ -878,7 +878,7 @@ def thing
878878
end
879879

880880
query(Query)
881-
orphan_types(ThingScalar, ThingEnum, ThingInput, ThingObject, ThingUnion, ThingInterface)
881+
extra_types(ThingScalar, ThingEnum, ThingInput, ThingObject, ThingUnion, ThingInterface)
882882
end
883883
end
884884

spec/graphql/schema/printer_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ class Subscription < GraphQL::Schema::Object
114114
query(Query)
115115
mutation(Mutation)
116116
subscription(Subscription)
117-
orphan_types [Media]
118-
extra_types [MediaRating]
117+
extra_types [Media, MediaRating]
119118
end
120119

121120
let(:schema) { PrinterTestSchema }

0 commit comments

Comments
 (0)