Skip to content

Commit 3306cae

Browse files
committed
fix(handler): More details about parse error
1 parent 925a732 commit 3306cae

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/handler.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,9 @@ export function createHandler<RawRequest = unknown>(
390390
let document: DocumentNode;
391391
try {
392392
document = parse(query);
393-
} catch {
393+
} catch (err) {
394394
return [
395-
'GraphQL query syntax error',
395+
JSON.stringify({ errors: [err] }),
396396
{
397397
...(acceptedMediaType === 'application/json'
398398
? {
@@ -404,6 +404,12 @@ export function createHandler<RawRequest = unknown>(
404404
statusText: 'Bad Request',
405405
}),
406406
statusText: 'Bad Request',
407+
headers: {
408+
'content-type':
409+
acceptedMediaType === 'application/json'
410+
? 'application/json; charset=utf-8'
411+
: 'application/graphql+json; charset=utf-8',
412+
},
407413
},
408414
];
409415
}

0 commit comments

Comments
 (0)