Skip to content

Commit f26e794

Browse files
committed
GraphQLError: Minor changes from upstream
Replicates graphql/graphql-js@82900fa
1 parent 29034c2 commit f26e794

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/graphql/error/graphql_error.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,28 @@ def __init__(
119119
) -> None:
120120
super().__init__(message)
121121
self.message = message
122+
123+
if path and not isinstance(path, list):
124+
path = list(path)
125+
self.path = path or None # type: ignore
126+
self.original_error = original_error
127+
128+
# Compute list of blame nodes.
122129
if nodes and not isinstance(nodes, list):
123130
nodes = [nodes] # type: ignore
124131
self.nodes = nodes or None # type: ignore
132+
133+
# Compute locations in the source for the given nodes/positions.
125134
self.source = source
126135
if not source and nodes:
127136
node = nodes[0] # type: ignore
128137
if node and node.loc and node.loc.source:
129138
self.source = node.loc.source
139+
130140
if not positions and nodes:
131141
positions = [node.loc.start for node in nodes if node.loc] # type: ignore
132142
self.positions = positions or None
143+
133144
if positions and source:
134145
locations: Optional[List["SourceLocation"]] = [
135146
source.get_location(pos) for pos in positions
@@ -143,10 +154,7 @@ def __init__(
143154
else:
144155
locations = None
145156
self.locations = locations
146-
if path and not isinstance(path, list):
147-
path = list(path)
148-
self.path = path or None # type: ignore
149-
self.original_error = original_error
157+
150158
if original_error:
151159
self.__traceback__ = original_error.__traceback__
152160
if original_error.__cause__:

0 commit comments

Comments
 (0)