Skip to content

Commit

Permalink
Rename repeatableisRepeatable
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegIlyenko committed Oct 4, 2018
1 parent ae9e7f9 commit 56fee7d
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/language/__tests__/schema-parser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ input Hello {
},
},
arguments: [],
repeatable: false,
isRepeatable: false,
locations: [
{
kind: 'Name',
Expand Down Expand Up @@ -874,7 +874,7 @@ input Hello {
},
},
arguments: [],
repeatable: true,
isRepeatable: true,
locations: [
{
kind: 'Name',
Expand Down
2 changes: 1 addition & 1 deletion src/language/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ export type DirectiveDefinitionNode = {
+description?: StringValueNode,
+name: NameNode,
+arguments?: $ReadOnlyArray<InputValueDefinitionNode>,
+repeatable: boolean,
+isRepeatable: boolean,
+locations: $ReadOnlyArray<NameNode>,
};

Expand Down
2 changes: 1 addition & 1 deletion src/language/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ function parseDirectiveDefinition(lexer: Lexer<*>): DirectiveDefinitionNode {
description,
name,
arguments: args,
repeatable,
isRepeatable: repeatable,
locations,
loc: loc(lexer, start),
};
Expand Down
4 changes: 2 additions & 2 deletions src/language/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, ' | '),
),
Expand Down
8 changes: 4 additions & 4 deletions src/type/__tests__/introspection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ describe('Introspection', () => {
args: [],
deprecationReason: null,
isDeprecated: false,
name: 'repeatable',
name: 'isRepeatable',
type: {
kind: 'NON_NULL',
name: null,
Expand Down Expand Up @@ -921,7 +921,7 @@ describe('Introspection', () => {
defaultValue: null,
},
],
repeatable: false,
isRepeatable: false,
},
{
name: 'skip',
Expand All @@ -941,7 +941,7 @@ describe('Introspection', () => {
defaultValue: null,
},
],
repeatable: false,
isRepeatable: false,
},
{
name: 'deprecated',
Expand All @@ -957,7 +957,7 @@ describe('Introspection', () => {
defaultValue: '"No longer supported"',
},
],
repeatable: false,
isRepeatable: false,
},
]);
});
Expand Down
7 changes: 4 additions & 3 deletions src/type/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ export class GraphQLDirective {
locations: Array<DirectiveLocationEnum>;
args: Array<GraphQLArgument>;
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(
Expand Down Expand Up @@ -95,7 +96,7 @@ export type GraphQLDirectiveConfig = {|
locations: Array<DirectiveLocationEnum>,
args?: ?GraphQLFieldConfigArgumentMap,
astNode?: ?DirectiveDefinitionNode,
repeatable?: ?boolean,
isRepeatable?: ?boolean,
|};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/type/introspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}),
});
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/__tests__/buildASTSchema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/__tests__/buildClientSchema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
}),
],
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/__tests__/extendSchema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const RepeatableDirective = new GraphQLDirective({
args: {
input: { type: SomeInputType },
},
repeatable: true,
isRepeatable: true,
locations: [DirectiveLocation.OBJECT, DirectiveLocation.INTERFACE],
});

Expand Down
4 changes: 2 additions & 2 deletions src/utilities/__tests__/schemaPrinter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ describe('Type System Printer', () => {
args: [__InputValue!]!
"""Permits using the directive multiple times at the same location."""
repeatable: Boolean!
isRepeatable: Boolean!
}
"""
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/buildASTSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export class ASTDefinitionBuilder {
args:
directiveNode.arguments &&
this._makeInputValues(directiveNode.arguments),
repeatable: directiveNode.repeatable,
isRepeatable: directiveNode.isRepeatable,
astNode: directiveNode,
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/utilities/buildClientSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/utilities/extendSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export function extendSchema(
locations: directive.locations,
args: extendArgs(directive.args),
astNode: directive.astNode,
repeatable: directive.repeatable,
isRepeatable: directive.isRepeatable,
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/utilities/findBreakingChanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down
6 changes: 3 additions & 3 deletions src/utilities/introspectionQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
|};
Expand All @@ -38,7 +38,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
args {
...InputValue
}
${directiveRepeatableFlag ? 'repeatable' : ''}
${directiveRepeatableFlag ? 'isRepeatable' : ''}
}
}
}
Expand Down Expand Up @@ -279,5 +279,5 @@ export type IntrospectionDirective = {|
+description?: ?string,
+locations: $ReadOnlyArray<DirectiveLocationEnum>,
+args: $ReadOnlyArray<IntrospectionInputValue>,
+repeatable?: boolean,
+isRepeatable?: boolean,
|};
2 changes: 1 addition & 1 deletion src/utilities/schemaPrinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(' | ')
);
Expand Down
2 changes: 1 addition & 1 deletion src/validation/__tests__/harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export const testSchema = new GraphQLSchema({
description: 'Some generic ID.',
},
},
repeatable: true,
isRepeatable: true,
locations: ['OBJECT'],
}),
],
Expand Down
4 changes: 2 additions & 2 deletions src/validation/rules/UniqueDirectivesPerLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 56fee7d

Please sign in to comment.