@@ -3,6 +3,8 @@ import path from "path";
3
3
import { getDiff } from "../diff" ;
4
4
import { getIntrospectionQuery , parse , print } from "graphql" ;
5
5
import introspectionResponse from "./fixtures/introspectionResponse.json" ;
6
+ import { graphql , buildSchema } from "graphql" ;
7
+ import fs from "fs/promises" ;
6
8
7
9
describe ( "getDiff" , ( ) => {
8
10
describe ( "remote schema fetching" , ( ) => {
@@ -261,4 +263,63 @@ describe("getDiff", () => {
261
263
expect ( result ) . toBeUndefined ( ) ;
262
264
} ) ;
263
265
} ) ;
266
+
267
+ describe ( "input arg deprecation" , ( ) => {
268
+ it ( "introspection misses deprecated input args fields by default" , async ( ) => {
269
+ const localSchemaInputValueDeprecated = path . join (
270
+ __dirname ,
271
+ "fixtures/localSchemaInputValueDeprecated.graphql" ,
272
+ ) ;
273
+ const testRemoteSchemaLocation = "http://test/graphql" ;
274
+ const schema = buildSchema (
275
+ await fs . readFile ( localSchemaInputValueDeprecated , "utf-8" ) ,
276
+ ) ;
277
+
278
+ nock ( testRemoteSchemaLocation )
279
+ . post ( / .* / )
280
+ . reply ( 200 , ( _uri , source : { query : string } ) => {
281
+ return graphql ( { schema, source : source . query , rootValue : { } } ) ;
282
+ } ) ;
283
+
284
+ const result = await getDiff (
285
+ localSchemaInputValueDeprecated ,
286
+ testRemoteSchemaLocation ,
287
+ ) ;
288
+
289
+ expect ( result ) . toBeDefined ( ) ;
290
+
291
+ if ( result ) {
292
+ expect ( result . diff ) . toContain ( "+ field1(testInput1: String): String" ) ;
293
+ }
294
+ } ) ;
295
+
296
+ it ( "introspection sees deprecated input args when inputValueDeprecation specified" , async ( ) => {
297
+ const localSchemaInputValueDeprecated = path . join (
298
+ __dirname ,
299
+ "fixtures/localSchemaInputValueDeprecated.graphql" ,
300
+ ) ;
301
+ const testRemoteSchemaLocation = "http://test/graphql" ;
302
+ const schema = buildSchema (
303
+ await fs . readFile ( localSchemaInputValueDeprecated , "utf-8" ) ,
304
+ ) ;
305
+
306
+ nock ( testRemoteSchemaLocation )
307
+ . post ( / .* / )
308
+ . reply ( 200 , ( _uri , source : { query : string } ) => {
309
+ return graphql ( { schema, source : source . query , rootValue : { } } ) ;
310
+ } ) ;
311
+
312
+ const result = await getDiff (
313
+ testRemoteSchemaLocation ,
314
+ localSchemaInputValueDeprecated ,
315
+ { inputValueDeprecation : true } ,
316
+ ) ;
317
+
318
+ expect ( result ) . toBeUndefined ( ) ;
319
+ } ) ;
320
+
321
+ afterEach ( ( ) => {
322
+ nock . cleanAll ( ) ;
323
+ } ) ;
324
+ } ) ;
264
325
} ) ;
0 commit comments