Skip to content

Commit

Permalink
Move recommended rules to their own list
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Jun 21, 2024
1 parent 1c204af commit ea7ceb7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ export {
ValidationContext,
// All validation rules in the GraphQL Specification.
specifiedRules,
recommendedRules,
// Individual validation rules.
ExecutableDefinitionsRule,
FieldsOnCorrectTypeRule,
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ export {
ValidationContext,
// All validation rules in the GraphQL Specification.
specifiedRules,
recommendedRules,
// Individual validation rules.
ExecutableDefinitionsRule,
FieldsOnCorrectTypeRule,
Expand Down
2 changes: 1 addition & 1 deletion src/validation/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export { validate } from './validate';

export { ValidationContext, ValidationRule } from './ValidationContext';

export { specifiedRules } from './specifiedRules';
export { specifiedRules, recommendedRules } from './specifiedRules';

// Spec Section: "Executable Definitions"
export { ExecutableDefinitionsRule } from './rules/ExecutableDefinitionsRule';
Expand Down
2 changes: 1 addition & 1 deletion src/validation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export { ValidationContext } from './ValidationContext';
export type { ValidationRule } from './ValidationContext';

// All validation rules in the GraphQL Specification.
export { specifiedRules } from './specifiedRules';
export { specifiedRules, recommendedRules } from './specifiedRules';

// Spec Section: "Executable Definitions"
export { ExecutableDefinitionsRule } from './rules/ExecutableDefinitionsRule';
Expand Down
6 changes: 6 additions & 0 deletions src/validation/specifiedRules.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { ValidationRule, SDLValidationRule } from './ValidationContext';

/**
* Technically these aren't part of the spec but they are strongly encouraged
* validation rules.
*/
export const recommendedRules: ReadonlyArray<ValidationRule>;

/**
* This set includes all validation rules defined by the GraphQL spec.
*
Expand Down
9 changes: 7 additions & 2 deletions src/validation/specifiedRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ import { UniqueFieldDefinitionNamesRule } from './rules/UniqueFieldDefinitionNam
import { UniqueDirectiveNamesRule } from './rules/UniqueDirectiveNamesRule';
import { PossibleTypeExtensionsRule } from './rules/PossibleTypeExtensionsRule';

/**
* Technically these aren't part of the spec but they are strongly encouraged
* validation rules.
*/
export const recommendedRules = Object.freeze([MaxIntrospectionDepthRule]);

/**
* This set includes all validation rules defined by the GraphQL spec.
*
Expand Down Expand Up @@ -127,8 +133,7 @@ export const specifiedRules = Object.freeze([
VariablesInAllowedPositionRule,
OverlappingFieldsCanBeMergedRule,
UniqueInputFieldNamesRule,
// Technically this isn't part of the spec but it's a strongly encouraged validation rule.
MaxIntrospectionDepthRule,
...recommendedRules,
]);

/**
Expand Down

0 comments on commit ea7ceb7

Please sign in to comment.