Skip to content

utilities/extendSchema not appending SubscriptionType #1084

Closed
@edispring

Description

@edispring

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions