Skip to content

Commit f237b93

Browse files
committed
IDL: fix missing subscription support
1 parent 64cc32e commit f237b93

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/test/groovy/graphql/parser/IDLParserTest.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ three: [Number] @three
282282
schema @d1 @d2 {
283283
query: OpType1
284284
mutation: OpType2
285+
subscription: OpType3
285286
}
286287
"""
287288

@@ -293,6 +294,8 @@ schema @d1 @d2 {
293294
.add(new OperationTypeDefinition("query", new TypeName("OpType1")))
294295
schema.getOperationTypeDefinitions()
295296
.add(new OperationTypeDefinition("mutation", new TypeName("OpType2")))
297+
schema.getOperationTypeDefinitions()
298+
.add(new OperationTypeDefinition("subscription", new TypeName("OpType3")))
296299

297300
when:
298301
def document = new Parser().parseDocument(input)

src/test/groovy/graphql/schema/idl/SchemaGeneratorTest.groovy

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,4 +654,27 @@ class SchemaGeneratorTest extends Specification {
654654
def err = thrown(NotAnOutputTypeError.class)
655655
err.message == "expected OutputType, but found CharacterInput type"
656656
}
657+
658+
def "schema with subscription"() {
659+
given:
660+
def spec = """
661+
schema {
662+
query: Query
663+
subscription: Subscription
664+
}
665+
type Query {
666+
foo: String
667+
}
668+
669+
type Subscription {
670+
foo: String
671+
}
672+
"""
673+
when:
674+
def wiring = RuntimeWiring.newRuntimeWiring()
675+
.build()
676+
def schema = generateSchema(spec, wiring)
677+
then:
678+
schema.getSubscriptionType().name == "Subscription"
679+
}
657680
}

0 commit comments

Comments
 (0)