diff --git a/graphql/error/graphql_error.py b/graphql/error/graphql_error.py index d7a71a35..96c83f4c 100644 --- a/graphql/error/graphql_error.py +++ b/graphql/error/graphql_error.py @@ -79,6 +79,8 @@ class GraphQLError(Exception): "extensions", ) + __hash__ = Exception.__hash__ + def __init__( self, message: str, @@ -89,7 +91,7 @@ def __init__( original_error: Exception = None, extensions: Dict[str, Any] = None, ) -> None: - super(GraphQLError, self).__init__(message) + super().__init__(message) self.message = message if nodes and not isinstance(nodes, list): nodes = [nodes] # type: ignore diff --git a/tests/error/test_graphql_error.py b/tests/error/test_graphql_error.py index 13960624..80a083c3 100644 --- a/tests/error/test_graphql_error.py +++ b/tests/error/test_graphql_error.py @@ -126,3 +126,11 @@ def default_error_formatter_includes_extension_fields(): "path": None, "extensions": {"foo": "bar"}, } + + def is_hashable(): + hash(GraphQLError("msg")) + + def hashes_are_unique_per_instance(): + e1 = GraphQLError("msg") + e2 = GraphQLError("msg") + assert hash(e1) != hash(e2)