Skip to content

Commit cd7d8c6

Browse files
committed
Update more tests
1 parent cc32ec2 commit cd7d8c6

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

lib/graphql/schema.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ def orphan_types(*new_orphan_types)
862862
raise ArgumentError, <<~ERR
863863
Only object type classes should be added as `orphan_types(...)`.
864864
865-
- Remove these no-op types from `orphan_types`: #{non_object_types.map(&:inspect).join(", ")}
865+
- Remove these no-op types from `orphan_types`: #{non_object_types.map { |t| "#{t.inspect} (#{t.kind.name})"}.join(", ")}
866866
- See https://graphql-ruby.org/type_definitions/interfaces.html#orphan-types
867867
868868
To add other types to your schema, you might want `extra_types`: https://graphql-ruby.org/schema/definition.html#extra-types

spec/graphql/schema/dynamic_members_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ def actor
325325
def yell(scream:)
326326
scream
327327
end
328+
329+
# just to attach these to the schema:
330+
field :example_locale, Locale
331+
field :example_region, Region
328332
end
329333

330334
class BaseMutation < GraphQL::Schema::RelayClassicMutation
@@ -475,6 +479,8 @@ def legacy_schema_sdl
475479
type Query {
476480
actor: Actor
477481
add(left: Float!, right: Float!): String!
482+
exampleLocale: Locale
483+
exampleRegion: Region
478484
f1: String
479485
favoriteLanguage(lang: Language): Language!
480486
legacyThing(id: ID!): LegacyThing!
@@ -878,7 +884,6 @@ def thing
878884
end
879885

880886
query(Query)
881-
extra_types(ThingScalar, ThingEnum, ThingInput, ThingObject, ThingUnion, ThingInterface)
882887
end
883888
end
884889

spec/graphql/schema/printer_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class Query < GraphQL::Schema::Object
9292
field :no_fields_type, NoFields do
9393
argument :no_arguments_input, NoArguments
9494
end
95+
96+
field :example_media, Media
9597
end
9698

9799
class CreatePost < GraphQL::Schema::RelayClassicMutation
@@ -114,7 +116,7 @@ class Subscription < GraphQL::Schema::Object
114116
query(Query)
115117
mutation(Mutation)
116118
subscription(Subscription)
117-
extra_types [Media, MediaRating]
119+
extra_types [MediaRating]
118120
end
119121

120122
let(:schema) { PrinterTestSchema }
@@ -587,6 +589,7 @@ class Subscription < GraphQL::Schema::Object
587589
The query root of this schema
588590
"""
589591
type Query {
592+
exampleMedia: Media
590593
noFieldsType(noArgumentsInput: NoArguments!): NoFields
591594
post(
592595
deprecatedArg: String @deprecated(reason: "Use something else")
@@ -791,6 +794,7 @@ def self.visible?(member, ctx)
791794
The query root of this schema
792795
"""
793796
type Query {
797+
exampleMedia: Media
794798
noFieldsType(noArgumentsInput: NoArguments!): NoFields
795799
post(
796800
"""

spec/graphql/schema/union_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,12 @@ def unboxed_union
282282
possible_types object_type, GraphQL::Schema::LateBoundType.new("SomeInterface")
283283
end
284284

285+
object_type.field(:u, union_type)
286+
object_type.field(:i, interface_type)
287+
285288
err2 = assert_raises ArgumentError do
286289
Class.new(GraphQL::Schema) do
287290
query(object_type)
288-
orphan_types(union_type, interface_type)
289291
end
290292
end
291293

spec/graphql/schema/warden_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,8 @@ def self.visible?(member, context)
566566
assert_nil res["data"]["BagOfThings"]
567567
assert_equal [], res["data"]["Query"]["fields"]
568568

569-
# Unreferenced but still visible because orphan type
570-
schema.orphan_types([schema.find("BagOfThings")])
569+
# Unreferenced but still visible because extra type
570+
schema.extra_types([schema.find("BagOfThings")])
571571
res = schema.execute(query_string, context: { except: ->(m, _) { m.graphql_name == "bag" } })
572572
assert res["data"]["BagOfThings"]
573573
end

spec/graphql/schema_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class ExampleOptionEnum < GraphQL::Schema::Enum
164164

165165
expected_msg = "Only object type classes should be added as `orphan_types(...)`.
166166
167-
- Remove these no-op types from `orphan_types`: ExampleOptionEnum
167+
- Remove these no-op types from `orphan_types`: ExampleOptionEnum (ENUM)
168168
- See https://graphql-ruby.org/type_definitions/interfaces.html#orphan-types
169169
170170
To add other types to your schema, you might want `extra_types`: https://graphql-ruby.org/schema/definition.html#extra-types

0 commit comments

Comments
 (0)