Skip to content

Commit 17d4ad3

Browse files
committed
Add option to not include specifiedByUrl in introspection query
1 parent 64e8150 commit 17d4ad3

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

src/type/__tests__/introspection-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ describe('Introspection', () => {
3131
const source = getIntrospectionQuery({
3232
descriptions: false,
3333
directiveIsRepeatable: true,
34+
specifiedByUrl: true,
3435
});
3536

3637
const result = graphqlSync({ schema, source });

src/utilities/__tests__/buildClientSchema-test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ import { introspectionFromSchema } from '../introspectionFromSchema';
3333
* returns that schema printed as SDL.
3434
*/
3535
function cycleIntrospection(sdlString: string): string {
36-
const options = { directiveIsRepeatable: true };
36+
const options = {
37+
directiveIsRepeatable: true,
38+
specifiedByUrl: true,
39+
};
3740

3841
const serverSchema = buildSchema(sdlString);
3942
const initialIntrospection = introspectionFromSchema(serverSchema, options);

src/utilities/__tests__/getIntrospectionQuery-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,16 @@ describe('getIntrospectionQuery', () => {
5151
getIntrospectionQuery({ descriptions: false, schemaDescription: true }),
5252
).to.not.match(/\bdescription\b/);
5353
});
54+
55+
it('include "specifiedByUrl" field', () => {
56+
expect(getIntrospectionQuery()).to.not.match(/\bspecifiedByUrl\b/);
57+
58+
expect(getIntrospectionQuery({ specifiedByUrl: true })).to.match(
59+
/\bspecifiedByUrl\b/,
60+
);
61+
62+
expect(getIntrospectionQuery({ specifiedByUrl: false })).to.not.match(
63+
/\bspecifiedByUrl\b/,
64+
);
65+
});
5466
});

src/utilities/getIntrospectionQuery.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ export interface IntrospectionOptions {
66
// Default: true
77
descriptions: boolean;
88

9+
// Whether to include `specifiedByUrl` in the introspection result.
10+
// Default: false
11+
specifiedByUrl?: boolean;
12+
913
// Whether to include `isRepeatable` flag on directives.
1014
// Default: false
1115
directiveIsRepeatable?: boolean;

src/utilities/getIntrospectionQuery.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ export type IntrospectionOptions = {|
77
// Default: true
88
descriptions?: boolean,
99

10+
// Whether to include `specifiedByUrl` in the introspection result.
11+
// Default: false
12+
specifiedByUrl?: boolean,
13+
1014
// Whether to include `isRepeatable` field on directives.
1115
// Default: false
1216
directiveIsRepeatable?: boolean,
@@ -19,12 +23,16 @@ export type IntrospectionOptions = {|
1923
export function getIntrospectionQuery(options?: IntrospectionOptions): string {
2024
const optionsWithDefault = {
2125
descriptions: true,
26+
specifiedByUrl: false,
2227
directiveIsRepeatable: false,
2328
schemaDescription: false,
2429
...options,
2530
};
2631

2732
const descriptions = optionsWithDefault.descriptions ? 'description' : '';
33+
const specifiedByUrl = optionsWithDefault.specifiedByUrl
34+
? 'specifiedByUrl'
35+
: '';
2836
const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable
2937
? 'isRepeatable'
3038
: '';
@@ -58,7 +66,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
5866
kind
5967
name
6068
${descriptions}
61-
specifiedByUrl
69+
${specifiedByUrl}
6270
fields(includeDeprecated: true) {
6371
name
6472
${descriptions}

0 commit comments

Comments
 (0)