diff --git a/src/language/__tests__/schema-parser-test.js b/src/language/__tests__/schema-parser-test.js index 96beac4114..029b3411d2 100644 --- a/src/language/__tests__/schema-parser-test.js +++ b/src/language/__tests__/schema-parser-test.js @@ -823,7 +823,7 @@ input Hello { }, }, arguments: [], - repeatable: false, + isRepeatable: false, locations: [ { kind: 'Name', @@ -874,7 +874,7 @@ input Hello { }, }, arguments: [], - repeatable: true, + isRepeatable: true, locations: [ { kind: 'Name', diff --git a/src/language/ast.js b/src/language/ast.js index 8dee33c8a3..4b9906bb9a 100644 --- a/src/language/ast.js +++ b/src/language/ast.js @@ -508,7 +508,7 @@ export type DirectiveDefinitionNode = { +description?: StringValueNode, +name: NameNode, +arguments?: $ReadOnlyArray, - +repeatable: boolean, + +isRepeatable: boolean, +locations: $ReadOnlyArray, }; diff --git a/src/language/parser.js b/src/language/parser.js index ddc728b941..7b6d621bf4 100644 --- a/src/language/parser.js +++ b/src/language/parser.js @@ -1395,7 +1395,7 @@ function parseDirectiveDefinition(lexer: Lexer<*>): DirectiveDefinitionNode { description, name, arguments: args, - repeatable, + isRepeatable: repeatable, locations, loc: loc(lexer, start), }; diff --git a/src/language/printer.js b/src/language/printer.js index f9d7cadd26..e72a9d67f7 100644 --- a/src/language/printer.js +++ b/src/language/printer.js @@ -181,13 +181,13 @@ const printDocASTReducer = { ), DirectiveDefinition: addDescription( - ({ name, arguments: args, locations, repeatable }) => + ({ name, arguments: args, locations, isRepeatable }) => 'directive @' + name + (args.every(arg => arg.indexOf('\n') === -1) ? wrap('(', join(args, ', '), ')') : wrap('(\n', indent(join(args, '\n')), '\n)')) + - (repeatable ? ' repeatable' : '') + + (isRepeatable ? ' repeatable' : '') + ' on ' + join(locations, ' | '), ), diff --git a/src/type/__tests__/introspection-test.js b/src/type/__tests__/introspection-test.js index 41e0c81417..2dc82784f4 100644 --- a/src/type/__tests__/introspection-test.js +++ b/src/type/__tests__/introspection-test.js @@ -704,7 +704,7 @@ describe('Introspection', () => { args: [], deprecationReason: null, isDeprecated: false, - name: 'repeatable', + name: 'isRepeatable', type: { kind: 'NON_NULL', name: null, @@ -921,7 +921,7 @@ describe('Introspection', () => { defaultValue: null, }, ], - repeatable: false, + isRepeatable: false, }, { name: 'skip', @@ -941,7 +941,7 @@ describe('Introspection', () => { defaultValue: null, }, ], - repeatable: false, + isRepeatable: false, }, { name: 'deprecated', @@ -957,7 +957,7 @@ describe('Introspection', () => { defaultValue: '"No longer supported"', }, ], - repeatable: false, + isRepeatable: false, }, ]); }); diff --git a/src/type/directives.js b/src/type/directives.js index f24603fda3..4c9c5d68fd 100644 --- a/src/type/directives.js +++ b/src/type/directives.js @@ -44,14 +44,15 @@ export class GraphQLDirective { locations: Array; args: Array; astNode: ?DirectiveDefinitionNode; - repeatable: boolean; + isRepeatable: boolean; constructor(config: GraphQLDirectiveConfig): void { this.name = config.name; this.description = config.description; this.locations = config.locations; this.astNode = config.astNode; - this.repeatable = config.repeatable == null ? false : config.repeatable; + this.isRepeatable = + config.isRepeatable == null ? false : config.isRepeatable; invariant(config.name, 'Directive must be named.'); invariant( @@ -95,7 +96,7 @@ export type GraphQLDirectiveConfig = {| locations: Array, args?: ?GraphQLFieldConfigArgumentMap, astNode?: ?DirectiveDefinitionNode, - repeatable?: ?boolean, + isRepeatable?: ?boolean, |}; /** diff --git a/src/type/introspection.js b/src/type/introspection.js index f8cf49f075..8493470992 100644 --- a/src/type/introspection.js +++ b/src/type/introspection.js @@ -98,11 +98,11 @@ export const __Directive = new GraphQLObjectType({ type: GraphQLNonNull(GraphQLList(GraphQLNonNull(__InputValue))), resolve: directive => directive.args || [], }, - repeatable: { + isRepeatable: { type: GraphQLNonNull(GraphQLBoolean), description: 'Permits using the directive multiple times at the same location.', - resolve: directive => directive.repeatable, + resolve: directive => directive.isRepeatable, }, }), }); diff --git a/src/utilities/__tests__/buildASTSchema-test.js b/src/utilities/__tests__/buildASTSchema-test.js index 7b5b43809f..3f526228d2 100644 --- a/src/utilities/__tests__/buildASTSchema-test.js +++ b/src/utilities/__tests__/buildASTSchema-test.js @@ -104,7 +104,7 @@ describe('Schema Builder', () => { expect(output).to.equal(body); const schema = buildASTSchema(parse(body)); - expect(schema.getDirective('foo').repeatable).to.equal(true); + expect(schema.getDirective('foo').isRepeatable).to.equal(true); }); it('Supports descriptions', () => { diff --git a/src/utilities/__tests__/buildClientSchema-test.js b/src/utilities/__tests__/buildClientSchema-test.js index 5429d5f8d7..91db2c8767 100644 --- a/src/utilities/__tests__/buildClientSchema-test.js +++ b/src/utilities/__tests__/buildClientSchema-test.js @@ -596,7 +596,7 @@ describe('Type System: build schema from introspection', () => { new GraphQLDirective({ name: 'customRepeatableDirective', description: 'This is a custom repeatable directive', - repeatable: true, + isRepeatable: true, locations: ['FIELD'], }), ], diff --git a/src/utilities/__tests__/extendSchema-test.js b/src/utilities/__tests__/extendSchema-test.js index eb13748b7a..97b9021467 100644 --- a/src/utilities/__tests__/extendSchema-test.js +++ b/src/utilities/__tests__/extendSchema-test.js @@ -120,7 +120,7 @@ const RepeatableDirective = new GraphQLDirective({ args: { input: { type: SomeInputType }, }, - repeatable: true, + isRepeatable: true, locations: [DirectiveLocation.OBJECT, DirectiveLocation.INTERFACE], }); diff --git a/src/utilities/__tests__/schemaPrinter-test.js b/src/utilities/__tests__/schemaPrinter-test.js index 08fc91f940..419f990972 100644 --- a/src/utilities/__tests__/schemaPrinter-test.js +++ b/src/utilities/__tests__/schemaPrinter-test.js @@ -652,7 +652,7 @@ describe('Type System Printer', () => { args: [__InputValue!]! """Permits using the directive multiple times at the same location.""" - repeatable: Boolean! + isRepeatable: Boolean! } """ @@ -888,7 +888,7 @@ describe('Type System Printer', () => { args: [__InputValue!]! # Permits using the directive multiple times at the same location. - repeatable: Boolean! + isRepeatable: Boolean! } # A Directive can be adjacent to many parts of the GraphQL language, a diff --git a/src/utilities/buildASTSchema.js b/src/utilities/buildASTSchema.js index 3354198db6..f3dfcc57fb 100644 --- a/src/utilities/buildASTSchema.js +++ b/src/utilities/buildASTSchema.js @@ -282,7 +282,7 @@ export class ASTDefinitionBuilder { args: directiveNode.arguments && this._makeInputValues(directiveNode.arguments), - repeatable: directiveNode.repeatable, + isRepeatable: directiveNode.isRepeatable, astNode: directiveNode, }); } diff --git a/src/utilities/buildClientSchema.js b/src/utilities/buildClientSchema.js index d1da2eb013..3f267a185f 100644 --- a/src/utilities/buildClientSchema.js +++ b/src/utilities/buildClientSchema.js @@ -355,10 +355,10 @@ export function buildClientSchema( description: directiveIntrospection.description, locations: directiveIntrospection.locations.slice(), args: buildInputValueDefMap(directiveIntrospection.args), - repeatable: - directiveIntrospection.repeatable === undefined + isRepeatable: + directiveIntrospection.isRepeatable === undefined ? false - : directiveIntrospection.repeatable, + : directiveIntrospection.isRepeatable, }); } diff --git a/src/utilities/extendSchema.js b/src/utilities/extendSchema.js index 21ce29973c..ca6338332b 100644 --- a/src/utilities/extendSchema.js +++ b/src/utilities/extendSchema.js @@ -320,7 +320,7 @@ export function extendSchema( locations: directive.locations, args: extendArgs(directive.args), astNode: directive.astNode, - repeatable: directive.repeatable, + isRepeatable: directive.isRepeatable, }); } diff --git a/src/utilities/findBreakingChanges.js b/src/utilities/findBreakingChanges.js index 6a77981a4b..36669cd224 100644 --- a/src/utilities/findBreakingChanges.js +++ b/src/utilities/findBreakingChanges.js @@ -856,7 +856,7 @@ export function findRemovedDirectiveRepeatable( continue; } - if (oldDirective.repeatable && !newDirective.repeatable) { + if (oldDirective.isRepeatable && !newDirective.isRepeatable) { removedRepeatable.push({ type: BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED, description: `Repeatable flag was removed from ${newDirective.name}`, diff --git a/src/utilities/introspectionQuery.js b/src/utilities/introspectionQuery.js index 330f241947..f3ed594d1a 100644 --- a/src/utilities/introspectionQuery.js +++ b/src/utilities/introspectionQuery.js @@ -13,7 +13,7 @@ export type IntrospectionOptions = {| // Whether to include descriptions in the introspection result. // Default: true descriptions: boolean, - // Whether to include `repeatable` flag on directives. + // Whether to include `isRepeatable` flag on directives. // Default: false directiveRepeatableFlag?: ?boolean, |}; @@ -38,7 +38,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string { args { ...InputValue } - ${directiveRepeatableFlag ? 'repeatable' : ''} + ${directiveRepeatableFlag ? 'isRepeatable' : ''} } } } @@ -279,5 +279,5 @@ export type IntrospectionDirective = {| +description?: ?string, +locations: $ReadOnlyArray, +args: $ReadOnlyArray, - +repeatable?: boolean, + +isRepeatable?: boolean, |}; diff --git a/src/utilities/schemaPrinter.js b/src/utilities/schemaPrinter.js index f6572a7283..15ee31fe65 100644 --- a/src/utilities/schemaPrinter.js +++ b/src/utilities/schemaPrinter.js @@ -309,7 +309,7 @@ function printDirective(directive, options) { 'directive @' + directive.name + printArgs(options, directive.args) + - (directive.repeatable ? ' repeatable' : '') + + (directive.isRepeatable ? ' repeatable' : '') + ' on ' + directive.locations.join(' | ') ); diff --git a/src/validation/__tests__/harness.js b/src/validation/__tests__/harness.js index 2b4c4a6f14..c5ce1b5221 100644 --- a/src/validation/__tests__/harness.js +++ b/src/validation/__tests__/harness.js @@ -396,7 +396,7 @@ export const testSchema = new GraphQLSchema({ description: 'Some generic ID.', }, }, - repeatable: true, + isRepeatable: true, locations: ['OBJECT'], }), ], diff --git a/src/validation/rules/UniqueDirectivesPerLocation.js b/src/validation/rules/UniqueDirectivesPerLocation.js index fb2782bc7a..a4eef87bc6 100644 --- a/src/validation/rules/UniqueDirectivesPerLocation.js +++ b/src/validation/rules/UniqueDirectivesPerLocation.js @@ -40,13 +40,13 @@ export function UniqueDirectivesPerLocation( ? schema.getDirectives() : specifiedDirectives; for (const directive of definedDirectives) { - uniqueDirectiveMap[directive.name] = !directive.repeatable; + uniqueDirectiveMap[directive.name] = !directive.isRepeatable; } const astDefinitions = context.getDocument().definitions; for (const def of astDefinitions) { if (def.kind === Kind.DIRECTIVE_DEFINITION) { - uniqueDirectiveMap[def.name.value] = !def.repeatable; + uniqueDirectiveMap[def.name.value] = !def.isRepeatable; } }