Skip to content

Commit 5e0d87a

Browse files
NyanKiyoshiCito
NyanKiyoshi
authored andcommitted
Fixed crash occurring when one sends a query containing type definitions (#257)
1 parent 1c319c4 commit 5e0d87a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

graphql/execution/tests/test_executor.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from pytest import raises
55

66
from graphql.error import GraphQLError
7-
from graphql.execution import MiddlewareManager, execute
7+
from graphql.execution import execute
8+
from graphql.language.ast import ObjectTypeDefinition
89
from graphql.language.parser import parse
910
from graphql.type import (
1011
GraphQLArgument,
@@ -553,11 +554,18 @@ def test_fails_to_execute_a_query_containing_a_type_definition():
553554
with raises(GraphQLError) as excinfo:
554555
execute(schema, query)
555556

557+
error = excinfo.value
558+
556559
assert (
557-
excinfo.value.message
560+
error.message
558561
== "GraphQL cannot execute a request containing a ObjectTypeDefinition."
559562
)
560563

564+
nodes = error.nodes
565+
assert type(nodes) is list
566+
assert len(nodes) == 1
567+
assert isinstance(nodes[0], ObjectTypeDefinition)
568+
561569

562570
def test_exceptions_are_reraised_if_specified(mocker):
563571
# type: (MockFixture) -> None

graphql/execution/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(
9898
u"GraphQL cannot execute a request containing a {}.".format(
9999
definition.__class__.__name__
100100
),
101-
definition,
101+
[definition],
102102
)
103103

104104
if not operation:

0 commit comments

Comments
 (0)