Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utilities/extendSchema not appending SubscriptionType #1084

Closed
edispring opened this issue Nov 8, 2017 · 2 comments
Closed

utilities/extendSchema not appending SubscriptionType #1084

edispring opened this issue Nov 8, 2017 · 2 comments

Comments

@edispring
Copy link

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
@leebyron
Copy link
Contributor

Currently, extendSchema only extends existing types and does not add new root types to the schema - however this is certainly something to be investigated

@flchaux
Copy link

flchaux commented Apr 25, 2023

@leebyron no news on this ? I've the same issue with Mutation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants