Skip to content

Subscription queries made against a schema that doesn't support subscriptions should result in a GraphQLError #875

Closed

Description

@tinnou

Issue

Related to #349, if a subscription query is attempted against a schema that doesn't support subscriptions, we raise an AssertException instead of a GraphQLError.

Steps to reproduce

The test below showcases the issue by making a subscription query against a schema that has no root subscription type defined.

def "a subscription query against a schema that doesn't support subscriptions should result in a GraphQL error"() {
        given:

        GraphQLSchema schema = newSchema().query(
                newObject()
                        .name("Query")
        )
                .build()

        when:
        def result = new GraphQL(schema).execute("subscription { doesNotExist }")

        then:
        result.errors.size() == 1
        result.errors[0].class == MissingRootTypeException
    }

will throw

graphql.AssertException: you must provide a graphql type

	at graphql.Assert.assertNotNull(Assert.java:12)
	at graphql.execution.ExecutionTypeInfo.<init>(ExecutionTypeInfo.java:37)
	at graphql.execution.ExecutionTypeInfo.<init>(ExecutionTypeInfo.java:23)
	at graphql.execution.ExecutionTypeInfo$Builder.build(ExecutionTypeInfo.java:237)
	at graphql.execution.Execution.executeOperation(Execution.java:140)
	at graphql.execution.Execution.execute(Execution.java:98)
	at graphql.GraphQL.execute(GraphQL.java:546)
	at graphql.GraphQL.parseValidateAndExecute(GraphQL.java:488)
	at graphql.GraphQL.executeAsync(GraphQL.java:463)
	at graphql.GraphQL.execute(GraphQL.java:394)
	at graphql.GraphQL.execute(GraphQL.java:265)
	at graphql.GraphQLTest.null subscription type should result in a GraphQL error(GraphQLTest.groovy:282)

Expected behavior

A regular GraphQLError should be returned, similar to what is currently being done with mutations.

Activity

  1. modified the milestones: 6.1, 7.0 on Jan 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions