Commit 16c9600 1 parent fed0f01 commit 16c9600 Copy full SHA for 16c9600
File tree 2 files changed +25
-26
lines changed
2 files changed +25
-26
lines changed Original file line number Diff line number Diff line change 4
4
*
5
5
*/
6
6
7
- import type { DocumentNode , GraphQLError } from 'graphql' ;
7
+ import type { GraphQLError } from 'graphql' ;
8
8
import { isObject } from './utils' ;
9
9
10
10
/**
@@ -36,7 +36,7 @@ export const TOKEN_QUERY_KEY = 'token' as const;
36
36
*/
37
37
export interface RequestParams {
38
38
operationName ?: string ;
39
- query : DocumentNode | string ;
39
+ query : string ;
40
40
variables ?: Record < string , unknown > ;
41
41
extensions ?: Record < string , unknown > ;
42
42
}
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
13
13
validate as graphqlValidate ,
14
14
execute as graphqlExecute ,
15
15
subscribe as graphqlSubscribe ,
16
+ DocumentNode ,
16
17
} from 'graphql' ;
17
18
import { isObject } from './utils' ;
18
19
import {
@@ -605,31 +606,29 @@ export function createHandler<
605
606
if ( ! schema ) throw new Error ( 'The GraphQL schema is not provided' ) ;
606
607
607
608
const { operationName, variables } = params ;
608
- let { query } = params ;
609
+ let query : DocumentNode ;
609
610
610
- if ( typeof query === 'string' ) {
611
- try {
612
- query = parse ( query ) ;
613
- } catch ( err ) {
614
- return [
615
- JSON . stringify ( {
616
- errors : [
617
- err instanceof Error
618
- ? {
619
- message : err . message ,
620
- // TODO: stack might leak sensitive information
621
- // stack: err.stack,
622
- }
623
- : err ,
624
- ] ,
625
- } ) ,
626
- {
627
- status : 400 ,
628
- statusText : 'Bad Request' ,
629
- headers : { 'content-type' : 'application/json; charset=utf-8' } ,
630
- } ,
631
- ] ;
632
- }
611
+ try {
612
+ query = parse ( params . query ) ;
613
+ } catch ( err ) {
614
+ return [
615
+ JSON . stringify ( {
616
+ errors : [
617
+ err instanceof Error
618
+ ? {
619
+ message : err . message ,
620
+ // TODO: stack might leak sensitive information
621
+ // stack: err.stack,
622
+ }
623
+ : err ,
624
+ ] ,
625
+ } ) ,
626
+ {
627
+ status : 400 ,
628
+ statusText : 'Bad Request' ,
629
+ headers : { 'content-type' : 'application/json; charset=utf-8' } ,
630
+ } ,
631
+ ] ;
633
632
}
634
633
635
634
const argsWithoutSchema = {
You can’t perform that action at this time.
0 commit comments