File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -282,6 +282,7 @@ three: [Number] @three
282282schema @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)
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments