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..a6d20a08a58 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: true + 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..03431ee7a41 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: true + 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}