Skip to content

Commit 3b5bf03

Browse files
committed
Skip repeatable flag by default in the introspection.
1 parent f8378d0 commit 3b5bf03

File tree

2 files changed

+81
-4
lines changed

2 files changed

+81
-4
lines changed

src/type/__tests__/introspection-test.js

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,6 @@ describe('Introspection', () => {
830830
directives: [
831831
{
832832
name: 'include',
833-
repeatable: false,
834833
locations: ['FIELD', 'FRAGMENT_SPREAD', 'INLINE_FRAGMENT'],
835834
args: [
836835
{
@@ -850,7 +849,6 @@ describe('Introspection', () => {
850849
},
851850
{
852851
name: 'skip',
853-
repeatable: false,
854852
locations: ['FIELD', 'FRAGMENT_SPREAD', 'INLINE_FRAGMENT'],
855853
args: [
856854
{
@@ -870,7 +868,6 @@ describe('Introspection', () => {
870868
},
871869
{
872870
name: 'deprecated',
873-
repeatable: false,
874871
locations: ['FIELD_DEFINITION', 'ENUM_VALUE'],
875872
args: [
876873
{
@@ -890,6 +887,81 @@ describe('Introspection', () => {
890887
});
891888
});
892889

890+
it('includes repeatable flag on directives', () => {
891+
const EmptySchema = new GraphQLSchema({
892+
query: new GraphQLObjectType({
893+
name: 'QueryRoot',
894+
fields: {
895+
onlyField: { type: GraphQLString },
896+
},
897+
}),
898+
});
899+
const query = getIntrospectionQuery({
900+
descriptions: false,
901+
directiveRepeatableFlag: true,
902+
});
903+
const result = graphqlSync(EmptySchema, query);
904+
905+
expect((result.data: any).__schema.directives).to.deep.equal([
906+
{
907+
name: 'include',
908+
locations: ['FIELD', 'FRAGMENT_SPREAD', 'INLINE_FRAGMENT'],
909+
args: [
910+
{
911+
name: 'if',
912+
type: {
913+
kind: 'NON_NULL',
914+
name: null,
915+
ofType: {
916+
kind: 'SCALAR',
917+
name: 'Boolean',
918+
ofType: null,
919+
},
920+
},
921+
defaultValue: null,
922+
},
923+
],
924+
repeatable: false,
925+
},
926+
{
927+
name: 'skip',
928+
locations: ['FIELD', 'FRAGMENT_SPREAD', 'INLINE_FRAGMENT'],
929+
args: [
930+
{
931+
name: 'if',
932+
type: {
933+
kind: 'NON_NULL',
934+
name: null,
935+
ofType: {
936+
kind: 'SCALAR',
937+
name: 'Boolean',
938+
ofType: null,
939+
},
940+
},
941+
defaultValue: null,
942+
},
943+
],
944+
repeatable: false,
945+
},
946+
{
947+
name: 'deprecated',
948+
locations: ['FIELD_DEFINITION', 'ENUM_VALUE'],
949+
args: [
950+
{
951+
name: 'reason',
952+
type: {
953+
kind: 'SCALAR',
954+
name: 'String',
955+
ofType: null,
956+
},
957+
defaultValue: '"No longer supported"',
958+
},
959+
],
960+
repeatable: false,
961+
},
962+
]);
963+
});
964+
893965
it('introspects on input object', () => {
894966
const TestInputObject = new GraphQLInputObjectType({
895967
name: 'TestInputObject',

src/utilities/introspectionQuery.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ export type IntrospectionOptions = {|
1313
// Whether to include descriptions in the introspection result.
1414
// Default: true
1515
descriptions: boolean,
16+
// Whether to include `repeatable` flag on directives.
17+
// Default: false
18+
directiveRepeatableFlag?: ?boolean,
1619
|};
1720

1821
export function getIntrospectionQuery(options?: IntrospectionOptions): string {
1922
const descriptions = !(options && options.descriptions === false);
23+
const directiveRepeatableFlag =
24+
options && options.directiveRepeatableFlag === true;
2025
return `
2126
query IntrospectionQuery {
2227
__schema {
@@ -33,7 +38,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
3338
args {
3439
...InputValue
3540
}
36-
repeatable
41+
${directiveRepeatableFlag ? 'repeatable' : ''}
3742
}
3843
}
3944
}

0 commit comments

Comments
 (0)