@@ -3,6 +3,8 @@ import path from "path";
33import { getDiff } from "../diff" ;
44import { getIntrospectionQuery , parse , print } from "graphql" ;
55import introspectionResponse from "./fixtures/introspectionResponse.json" ;
6+ import { graphql , buildSchema } from "graphql" ;
7+ import fs from "fs/promises" ;
68
79describe ( "getDiff" , ( ) => {
810 describe ( "remote schema fetching" , ( ) => {
@@ -261,4 +263,63 @@ describe("getDiff", () => {
261263 expect ( result ) . toBeUndefined ( ) ;
262264 } ) ;
263265 } ) ;
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+ } ) ;
264325} ) ;
0 commit comments