diff --git a/graphql/error/base.py b/graphql/error/base.py index c57d0959..2ef93cd1 100644 --- a/graphql/error/base.py +++ b/graphql/error/base.py @@ -6,7 +6,7 @@ from ..language.source import Source from ..language.location import SourceLocation from types import TracebackType - from typing import Optional, List, Any, Union + from typing import Optional, List, Any, Union, Dict class GraphQLError(Exception): @@ -30,6 +30,7 @@ def __init__( positions=None, # type: Optional[Any] locations=None, # type: Optional[Any] path=None, # type: Union[List[Union[int, str]], List[str], None] + extensions=None # type: Optional[Dict[str, Any]] ): # type: (...) -> None super(GraphQLError, self).__init__(message) @@ -40,6 +41,7 @@ def __init__( self._positions = positions self._locations = locations self.path = path + self.extensions = extensions return None @property diff --git a/graphql/error/format_error.py b/graphql/error/format_error.py index fd162c82..d48a4e64 100644 --- a/graphql/error/format_error.py +++ b/graphql/error/format_error.py @@ -17,5 +17,7 @@ def format_error(error): ] if error.path is not None: formatted_error["path"] = error.path + if error.extensions is not None: + formatted_error["extensions"] = error.extensions return formatted_error