File tree Expand file tree Collapse file tree
packages/apollo-tools/src/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -390,5 +390,44 @@ type MutationRoot {
390390
391391 expect ( nameField . resolve ) . toEqual ( name ) ;
392392 } ) ;
393+
394+ it ( `should handle subscriptions` , ( ) => {
395+ const commentAddedSubscription = ( ) =>
396+ async function * ( ) {
397+ yield "111" ;
398+ yield "222" ;
399+ yield "333" ;
400+ } ;
401+
402+ const service = buildServiceDefinition ( [
403+ {
404+ typeDefs : gql `
405+ type Subscription {
406+ commentAdded: String
407+ }
408+ ` ,
409+ resolvers : {
410+ Subscription : {
411+ commentAdded : {
412+ subscribe : commentAddedSubscription
413+ }
414+ }
415+ }
416+ }
417+ ] ) ;
418+
419+ expect ( service . schema ) . toBeDefined ( ) ;
420+ const schema = service . schema ! ;
421+
422+ const subscriptionType = schema . getType ( "Subscription" ) ;
423+ expect ( subscriptionType ) . toBeDefined ( ) ;
424+
425+ const commentAdded = ( subscriptionType ! as GraphQLObjectType ) . getFields ( ) [
426+ "commentAdded"
427+ ] ;
428+ expect ( commentAdded ) . toBeDefined ( ) ;
429+
430+ expect ( commentAdded . subscribe ) . toEqual ( commentAddedSubscription ) ;
431+ } ) ;
393432 } ) ;
394433} ) ;
You can’t perform that action at this time.
0 commit comments