Closed
Description
We have an existing GraphQLSchema instance with no SubscriptionTypes and want to extend this schema with a new SubscriptionType. To extend we use the extendSchema utility. After extending the schema, the SubscriptionType is null on the new schema.
const todoType = new GraphQLObjectType({
name: 'Todo',
description: 'A task to be completed',
fields: {
id: { type: GraphQLID },
description: { type: GraphQLString },
completed: { type: GraphQLBoolean },
},
});
const queryType = new GraphQLObjectType({
name: 'QueryType',
fields: {
todo: {
type: todoType,
args: {
id: { type: GraphQLID },
},
},
},
});
// GraphQLSchema with no SubscriptionTypes
const schema = new GraphQLSchema({
query: queryType
});
const extension = `type Subscription {
todoCompleted: Todo
}`;
const extendedSchema = extendSchema(schema, parse(extension));
assert.ok(!!extendedSchema.getSubscriptionType()); // fails, extendedSchema.getSubscriptionType() is null