Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion graphql/error/graphql_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class GraphQLError(Exception):
"extensions",
)

__hash__ = Exception.__hash__

def __init__(
self,
message: str,
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions tests/error/test_graphql_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)