Skip to content

Commit 54c39da

Browse files
ccouzensfabsrc
authored andcommitted
Add a option to make deprecated input args visible
This caught us out, as when we removed a deprecated input arg is wasn't as visible as we'd have liked. By adding this option, we can have visiblity of deprecated input args.
1 parent bace558 commit 54c39da

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ $ graphql-schema-diff --help
3131
--left-schema-header Header to send to left remote schema source
3232
--right-schema-header Header to send to right remote schema source
3333
--sort-schema, -s Sort schemas prior to diffing
34+
--input-value-deprecation Include deprecated input value fields
3435

3536
Examples
3637
$ graphql-schema-diff https://example.com/graphql schema.graphql

npm-shrinkwrap.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"diff2html": "^3.4.35",
4545
"disparity": "^3.2.0",
4646
"fs-extra": "^11.1.1",
47-
"graphql": "^16.7.1",
47+
"graphql": "^16.8.1",
4848
"meow": "^9.0.0",
4949
"node-fetch": "^2.6.11"
5050
},

src/cli.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const cli = meow(
2020
--left-schema-header \t Header to send to left remote schema source
2121
--right-schema-header \t Header to send to right remote schema source
2222
--sort-schema, -s \t\t Sort schemas prior to diffing
23+
--input-value-deprecation \t Include deprecated input value fields
2324
2425
Examples
2526
$ graphql-schema-diff https://example.com/graphql schema.graphql
@@ -67,6 +68,9 @@ const cli = meow(
6768
version: {
6869
alias: "v",
6970
},
71+
inputValueDeprecation: {
72+
type: "boolean",
73+
},
7074
},
7175
},
7276
);
@@ -124,6 +128,7 @@ getDiff(leftSchemaLocation, rightSchemaLocation, {
124128
headers: parseHeaders(rightSchemaHeader),
125129
},
126130
sortSchema: cli.flags.sortSchema as boolean,
131+
inputValueDeprecation: cli.flags.inputValueDeprecation as boolean,
127132
})
128133
.then(async (result) => {
129134
if (result === undefined) {

src/diff.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from "graphql";
77
import { lexicographicSortSchema } from "graphql/utilities";
88
import disparity from "disparity";
9-
import { loadSchema } from "@graphql-tools/load";
9+
import { LoadSchemaOptions, loadSchema } from "@graphql-tools/load";
1010
import { UrlLoader } from "@graphql-tools/url-loader";
1111
import { JsonFileLoader } from "@graphql-tools/json-file-loader";
1212
import { printSchemaWithDirectives } from "@graphql-tools/utils";
@@ -31,18 +31,22 @@ export interface DiffOptions {
3131
};
3232
headers?: Headers;
3333
sortSchema?: boolean;
34+
inputValueDeprecation?: boolean;
3435
}
3536

3637
export async function getDiff(
3738
leftSchemaLocation: string,
3839
rightSchemaLocation: string,
3940
options: DiffOptions = {},
4041
): Promise<DiffResponse | undefined> {
41-
const getSchemaOptions = (customHeaders?: Headers) => ({
42+
const getSchemaOptions: (
43+
customHeaders?: Headers,
44+
) => Omit<LoadSchemaOptions, "loaders"> = (customHeaders) => ({
4245
headers: { ...options.headers, ...customHeaders },
4346
skipGraphQLImport: false,
4447
descriptions: false,
4548
customFetch: fetch,
49+
inputValueDeprecation: options.inputValueDeprecation,
4650
});
4751
const leftSchemaOptions = getSchemaOptions(options.leftSchema?.headers);
4852
const rightSchemaOptions = getSchemaOptions(options.rightSchema?.headers);

0 commit comments

Comments
 (0)