Skip to content

Commit 2207cce

Browse files
committed
GraphQLError: test that formatted dict has only prescribed keys
Replicates graphql/graphql-js@52f1754
1 parent 7ebe854 commit 2207cce

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/graphql/error/graphql_error.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ class GraphQLError(Exception):
5454
"""
5555

5656
message: str
57-
"""A message describing the Error for debugging purposes
58-
59-
Note: should be treated as readonly, despite invariant usage.
60-
"""
57+
"""A message describing the Error for debugging purposes"""
6158

6259
locations: Optional[List["SourceLocation"]]
6360
"""Source locations

tests/error/test_graphql_error.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ def has_a_name_message_extensions_and_stack_trace():
4747
assert e.__traceback__ is None
4848
assert str(e) == "msg"
4949

50+
def formatted_dict_has_only_keys_prescribed_in_the_spec():
51+
e = GraphQLError(
52+
"msg",
53+
[field_node],
54+
source,
55+
[1, 2, 3],
56+
["a", "b", "c"],
57+
Exception("test"),
58+
{"foo": "bar"})
59+
assert set(e.formatted) == {'message', 'path', 'locations', 'extensions'}
60+
5061
def uses_the_stack_of_an_original_error():
5162
try:
5263
raise RuntimeError("original")

0 commit comments

Comments
 (0)