Skip to content

Commit

Permalink
Add option to not include specifiedByUrl in introspection query
Browse files Browse the repository at this point in the history
  • Loading branch information
m14t committed Apr 28, 2020
1 parent 64e8150 commit 4dcf49b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/utilities/__tests__/getIntrospectionQuery-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/,
);
});
});
4 changes: 4 additions & 0 deletions src/utilities/getIntrospectionQuery.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion src/utilities/getIntrospectionQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'
: '';
Expand Down Expand Up @@ -58,7 +66,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
kind
name
${descriptions}
specifiedByUrl
${specifiedByUrl}
fields(includeDeprecated: true) {
name
${descriptions}
Expand Down

0 comments on commit 4dcf49b

Please sign in to comment.