Skip to content

Commit fec6b57

Browse files
committed
fix: properly type extensions in GraphQLFormattedError
Replicates graphql/graphql-js@3f49961e
1 parent 9a2b0a2 commit fec6b57

4 files changed

Lines changed: 25 additions & 3 deletions

File tree

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
FormattedSourceLocation
149149
GraphQLAbstractType
150150
GraphQLErrorExtensions
151+
GraphQLFormattedErrorExtensions
151152
GraphQLOutputType
152153
asyncio.events.AbstractEventLoop
153154
graphql.execution.map_async_iterator.MapAsyncIterator

src/graphql/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
GraphQLError,
4949
GraphQLErrorExtensions,
5050
GraphQLFormattedError,
51+
GraphQLFormattedErrorExtensions,
5152
GraphQLSyntaxError,
5253
located_error,
5354
)
@@ -748,6 +749,7 @@
748749
"GraphQLError",
749750
"GraphQLErrorExtensions",
750751
"GraphQLFormattedError",
752+
"GraphQLFormattedErrorExtensions",
751753
"GraphQLSyntaxError",
752754
"located_error",
753755
"get_introspection_query",

src/graphql/error/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
errors.
55
"""
66

7-
from .graphql_error import GraphQLError, GraphQLErrorExtensions, GraphQLFormattedError
7+
from .graphql_error import (
8+
GraphQLError,
9+
GraphQLErrorExtensions,
10+
GraphQLFormattedError,
11+
GraphQLFormattedErrorExtensions,
12+
)
813

914
from .syntax_error import GraphQLSyntaxError
1015

@@ -14,6 +19,7 @@
1419
"GraphQLError",
1520
"GraphQLErrorExtensions",
1621
"GraphQLFormattedError",
22+
"GraphQLFormattedErrorExtensions",
1723
"GraphQLSyntaxError",
1824
"located_error",
1925
]

src/graphql/error/graphql_error.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
) # noqa: F401
1515
from ..language.source import Source # noqa: F401
1616

17-
__all__ = ["GraphQLError", "GraphQLErrorExtensions", "GraphQLFormattedError"]
17+
__all__ = [
18+
"GraphQLError",
19+
"GraphQLErrorExtensions",
20+
"GraphQLFormattedError",
21+
"GraphQLFormattedErrorExtensions",
22+
]
1823

1924

2025
# Custom extensions
@@ -25,6 +30,14 @@
2530
# a dictionary which can contain all the values you need.
2631

2732

33+
# Custom formatted extensions
34+
GraphQLFormattedErrorExtensions = Dict[str, Any]
35+
# Use a unique identifier name for your extension, for example the name of
36+
# your library or project. Do not use a shortened identifier as this increases
37+
# the risk of conflicts. We recommend you add at most one extension key,
38+
# a dictionary which can contain all the values you need.
39+
40+
2841
class GraphQLFormattedError(TypedDict, total=False):
2942
"""Formatted GraphQL error"""
3043

@@ -41,7 +54,7 @@ class GraphQLFormattedError(TypedDict, total=False):
4154
path: List[Union[str, int]]
4255
# Reserved for implementors to extend the protocol however they see fit,
4356
# and hence there are no additional restrictions on its contents.
44-
extensions: GraphQLErrorExtensions
57+
extensions: GraphQLFormattedErrorExtensions
4558

4659

4760
class GraphQLError(Exception):

0 commit comments

Comments
 (0)