Skip to content

Commit 8065221

Browse files
committed
1 parent 4a94ae7 commit 8065221

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ a query language for APIs created by Facebook.
1212
[![Python 3 Status](https://pyup.io/repos/github/graphql-python/graphql-core/python-3-shield.svg)](https://pyup.io/repos/github/graphql-python/graphql-core/)
1313
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
1414

15-
The current version 3.1.6 of GraphQL-core is up-to-date with GraphQL.js version 15.5.1.
15+
The current version 3.1.6 of GraphQL-core is up-to-date with GraphQL.js version 15.7.1.
1616

1717
An extensive test suite with over 2200 unit tests and 100% coverage comprises a
1818
replication of the complete test suite of GraphQL.js, making sure this port is

src/graphql/error/graphql_error.py

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

2121
message: str
22-
"""A message describing the Error for debugging purposes
23-
24-
Note: should be treated as readonly, despite invariant usage.
25-
"""
22+
"""A message describing the Error for debugging purposes"""
2623

2724
locations: Optional[List["SourceLocation"]]
2825
"""Source locations

src/graphql/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
version = "3.1.6"
88

9-
version_js = "15.6.1"
9+
version_js = "15.7.1"
1010

1111

1212
_re_version = re.compile(r"(\d+)\.(\d+)\.(\d+)(\D*)(\d*)")

tests/error/test_graphql_error.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ def is_a_class_and_is_a_subclass_of_exception():
3636
assert isinstance(GraphQLError("str"), Exception)
3737
assert isinstance(GraphQLError("str"), GraphQLError)
3838

39-
def has_a_name_message_and_stack_trace():
39+
def has_a_name_message_extensions_and_stack_trace():
4040
e = GraphQLError("msg")
4141
assert e.__class__.__name__ == "GraphQLError"
4242
assert e.message == "msg"
43+
assert e.extensions == {}
44+
assert e.__traceback__ is None
45+
assert str(e) == "msg"
4346

4447
def uses_the_stack_of_an_original_error():
4548
try:
@@ -126,18 +129,27 @@ def converts_source_and_positions_to_locations():
126129
assert e.positions == [6]
127130
assert e.locations == [(2, 5)]
128131

129-
def serializes_to_include_message():
130-
e = GraphQLError("msg")
131-
assert str(e) == "msg"
132-
assert repr(e) == "GraphQLError('msg')"
133-
134-
def serializes_to_include_message_and_locations():
135-
e = GraphQLError("msg", field_node)
136-
assert "msg" in str(e)
137-
assert ":2:3" in str(e)
138-
assert repr(e) == (
139-
"GraphQLError('msg', locations=[SourceLocation(line=2, column=3)])"
132+
def serializes_to_include_all_standard_fields():
133+
e_short = GraphQLError("msg")
134+
assert str(e_short) == "msg"
135+
assert repr(e_short) == "GraphQLError('msg')"
136+
137+
path: List[Union[str, int]] = ["path", 2, "field"]
138+
extensions = {"foo": "bar "}
139+
e_full = GraphQLError("msg", field_node, None, None, path, None, extensions)
140+
assert str(e_full) == (
141+
"msg\n\nGraphQL request:2:3\n" "1 | {\n2 | field\n | ^\n3 | }"
142+
)
143+
assert repr(e_full) == (
144+
"GraphQLError('msg', locations=[SourceLocation(line=2, column=3)],"
145+
" path=['path', 2, 'field'], extensions={'foo': 'bar '})"
140146
)
147+
assert e_full.formatted == {
148+
"message": "msg",
149+
"locations": [{"line": 2, "column": 3}],
150+
"path": ["path", 2, "field"],
151+
"extensions": {"foo": "bar "},
152+
}
141153

142154
def repr_includes_extensions():
143155
e = GraphQLError("msg", extensions={"foo": "bar"})

0 commit comments

Comments
 (0)