Skip to content

Commit c228b01

Browse files
committed
Make sure GraphQLError can be initialized with a dict
Replicates graphql/graphql-js@a91fdc6
1 parent 2334451 commit c228b01

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/error/test_graphql_error.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,3 +389,20 @@ def includes_extension_fields():
389389
"message": "msg",
390390
"extensions": {"foo": "bar"},
391391
}
392+
393+
def can_be_created_from_dict():
394+
args = dict(
395+
nodes=[operation_node],
396+
source=source,
397+
positions=[6],
398+
path=["path", 2, "a"],
399+
original_error=Exception("I like turtles"),
400+
extensions=dict(hee="I like turtles"),
401+
)
402+
error = GraphQLError("msg", **args) # type: ignore
403+
assert error.formatted == {
404+
"message": "msg",
405+
"locations": [{"column": 5, "line": 2}],
406+
"path": ["path", 2, "a"],
407+
"extensions": {"hee": "I like turtles"},
408+
}

0 commit comments

Comments
 (0)