Skip to content

Commit 8bca471

Browse files
committed
Address @leebyron review comments
1 parent 744e1a1 commit 8bca471

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/error/__tests__/GraphQLError-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ describe('GraphQLError', () => {
136136
message: 'msg',
137137
locations: undefined,
138138
path: ['path', 3, 'to', 'field'],
139-
extensions: undefined,
140139
});
141140
});
142141

src/error/formatError.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@ import type { SourceLocation } from '../language/location';
1717
*/
1818
export function formatError(error: GraphQLError): GraphQLFormattedError {
1919
invariant(error, 'Received null or undefined error.');
20-
return {
21-
message: error.message || 'An unknown error occurred.',
22-
locations: error.locations,
23-
path: error.path,
24-
extensions: error.extensions,
25-
};
20+
const message = error.message || 'An unknown error occurred.';
21+
const locations = error.locations;
22+
const path = error.path;
23+
const extensions = error.extensions;
24+
25+
return extensions
26+
? { message, locations, path, extensions }
27+
: { message, locations, path };
2628
}
2729

2830
export type GraphQLFormattedError = {|
2931
+message: string,
3032
+locations: $ReadOnlyArray<SourceLocation> | void,
3133
+path: $ReadOnlyArray<string | number> | void,
32-
+extensions: { [key: string]: mixed } | void,
34+
+extensions?: { [key: string]: mixed },
3335
|};

0 commit comments

Comments
 (0)