From c4a6a0b0a6f5bbca7c59ae61b91a48510f1b6c55 Mon Sep 17 00:00:00 2001 From: Matt Farmer Date: Sat, 25 Apr 2020 10:10:09 -0700 Subject: [PATCH] Add option to not include `specifiedByUrl` in introspection query --- .../__tests__/getIntrospectionQuery-test.js | 12 ++++++++++++ src/utilities/getIntrospectionQuery.d.ts | 4 ++++ src/utilities/getIntrospectionQuery.js | 10 +++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/utilities/__tests__/getIntrospectionQuery-test.js b/src/utilities/__tests__/getIntrospectionQuery-test.js index e25a906e190..462d683acfa 100644 --- a/src/utilities/__tests__/getIntrospectionQuery-test.js +++ b/src/utilities/__tests__/getIntrospectionQuery-test.js @@ -51,4 +51,16 @@ describe('getIntrospectionQuery', () => { getIntrospectionQuery({ descriptions: false, schemaDescription: true }), ).to.not.match(/\bdescription\b/); }); + + it('include "specifiedByUrl" field', () => { + expect(getIntrospectionQuery()).to.not.match(/\bspecifiedByUrl\b/); + + expect(getIntrospectionQuery({ specifiedByUrl: true })).to.match( + /\bspecifiedByUrl\b/, + ); + + expect(getIntrospectionQuery({ specifiedByUrl: false })).to.not.match( + /\bspecifiedByUrl\b/, + ); + }); }); diff --git a/src/utilities/getIntrospectionQuery.d.ts b/src/utilities/getIntrospectionQuery.d.ts index da0fdcd1868..b1d5ecc1744 100644 --- a/src/utilities/getIntrospectionQuery.d.ts +++ b/src/utilities/getIntrospectionQuery.d.ts @@ -6,6 +6,10 @@ export interface IntrospectionOptions { // Default: true descriptions: boolean; + // Whether to include `specifiedByUrl` in the introspection result. + // Default: false + specifiedByUrl?: boolean; + // Whether to include `isRepeatable` flag on directives. // Default: false directiveIsRepeatable?: boolean; diff --git a/src/utilities/getIntrospectionQuery.js b/src/utilities/getIntrospectionQuery.js index 045faab732d..51e94cd9a18 100644 --- a/src/utilities/getIntrospectionQuery.js +++ b/src/utilities/getIntrospectionQuery.js @@ -7,6 +7,10 @@ export type IntrospectionOptions = {| // Default: true descriptions?: boolean, + // Whether to include `specifiedByUrl` in the introspection result. + // Default: false + specifiedByUrl?: boolean, + // Whether to include `isRepeatable` field on directives. // Default: false directiveIsRepeatable?: boolean, @@ -19,12 +23,16 @@ export type IntrospectionOptions = {| export function getIntrospectionQuery(options?: IntrospectionOptions): string { const optionsWithDefault = { descriptions: true, + specifiedByUrl: false, directiveIsRepeatable: false, schemaDescription: false, ...options, }; const descriptions = optionsWithDefault.descriptions ? 'description' : ''; + const specifiedByUrl = optionsWithDefault.specifiedByUrl + ? 'specifiedByUrl' + : ''; const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable ? 'isRepeatable' : ''; @@ -58,7 +66,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string { kind name ${descriptions} - specifiedByUrl + ${specifiedByUrl} fields(includeDeprecated: true) { name ${descriptions}