File tree 3 files changed +23
-11
lines changed 3 files changed +23
-11
lines changed Original file line number Diff line number Diff line change 1
- GO_RES_USER_TOKEN =
1
+ GO_RES_USER_TOKEN =
2
+ ENV =
Original file line number Diff line number Diff line change 1
1
import { config } from 'dotenv' ;
2
2
import { join } from 'path' ;
3
+ config ( ) ;
3
4
4
5
const environment = process . env . ENV ;
5
6
if ( ! environment ) throw new Error ( 'please pass the environment variable. Options: | dev | stage | prod |' ) ;
Original file line number Diff line number Diff line change @@ -2,17 +2,27 @@ import { ENV } from 'env/manager';
2
2
import supertest from 'supertest' ;
3
3
4
4
export const queryGraphQl = async ( token : string , graphQLQuery : string ) => {
5
- const response = await supertest ( ENV . BASEURL )
6
- . post ( ENV . ENDPOINT )
7
- . set ( { 'authorization' : `Bearer ${ token } ` } )
8
- . send ( { query : graphQLQuery } ) ;
9
- return response ;
5
+ try {
6
+ const response = await supertest ( ENV . BASEURL )
7
+ . post ( ENV . ENDPOINT )
8
+ . set ( { 'authorization' : `Bearer ${ token } ` } )
9
+ . send ( { query : graphQLQuery } ) ;
10
+ return response ;
11
+ } catch ( error ) {
12
+ console . error ( `Error making request to ${ ENV . BASEURL + ENV . ENDPOINT } :` , error ) ;
13
+ throw error ;
14
+ }
10
15
} ;
11
16
12
17
export const mutateGraphQl = async ( token : string , mutationPayload : string ) => {
13
- const response = await supertest ( ENV . BASEURL )
14
- . post ( ENV . ENDPOINT )
15
- . set ( { 'authorization' : `Bearer ${ token } ` } )
16
- . send ( { query : mutationPayload } ) ;
17
- return response ;
18
+ try {
19
+ const response = await supertest ( ENV . BASEURL )
20
+ . post ( ENV . ENDPOINT )
21
+ . set ( { 'authorization' : `Bearer ${ token } ` } )
22
+ . send ( { query : mutationPayload } ) ;
23
+ return response ;
24
+ } catch ( error ) {
25
+ console . error ( `Error making request to ${ ENV . BASEURL + ENV . ENDPOINT } :` , error ) ;
26
+ throw error ;
27
+ }
18
28
} ;
You can’t perform that action at this time.
0 commit comments