Skip to content

Fixed crash occurring when one sends a query containing type definitions #257

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions graphql/execution/tests/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from pytest import raises

from graphql.error import GraphQLError
from graphql.execution import MiddlewareManager, execute
from graphql.execution import execute
from graphql.language.ast import ObjectTypeDefinition
from graphql.language.parser import parse
from graphql.type import (
GraphQLArgument,
Expand Down Expand Up @@ -553,11 +554,18 @@ def test_fails_to_execute_a_query_containing_a_type_definition():
with raises(GraphQLError) as excinfo:
execute(schema, query)

error = excinfo.value

assert (
excinfo.value.message
error.message
== "GraphQL cannot execute a request containing a ObjectTypeDefinition."
)

nodes = error.nodes
assert type(nodes) is list
assert len(nodes) == 1
assert isinstance(nodes[0], ObjectTypeDefinition)


def test_exceptions_are_reraised_if_specified(mocker):
# type: (MockFixture) -> None
Expand Down
2 changes: 1 addition & 1 deletion graphql/execution/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __init__(
u"GraphQL cannot execute a request containing a {}.".format(
definition.__class__.__name__
),
definition,
[definition],
)

if not operation:
Expand Down