File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,17 @@ describe('getDiff', () => {
116
116
) . rejects . toThrow ( `404 - Not Found (${ testRemoteSchemaLocation } )` ) ;
117
117
} ) ;
118
118
119
+ it ( 'throws error on invalid response' , ( ) => {
120
+ nock ( testRemoteSchemaLocation )
121
+ . post ( '' , JSON . stringify ( { query : introspectionQuery } ) )
122
+ . twice ( )
123
+ . reply ( 200 , { invalid : 'response' } ) ;
124
+
125
+ return expect (
126
+ getDiff ( testRemoteSchemaLocation , testRemoteSchemaLocation )
127
+ ) . rejects . toThrow ( `Invalid response from GraphQL endpoint: ${ testRemoteSchemaLocation } ` ) ;
128
+ } ) ;
129
+
119
130
afterEach ( ( ) => {
120
131
nock . cleanAll ( ) ;
121
132
} ) ;
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ async function fetchRemoteSchema(
37
37
}
38
38
39
39
const responseBody = await res . json ( ) ;
40
-
40
+
41
41
if ( ! responseBody || ! responseBody . data || ! responseBody . data . __schema ) {
42
42
throw new Error ( `Invalid response from GraphQL endpoint: ${ endpoint } ` ) ;
43
43
}
You can’t perform that action at this time.
0 commit comments