specifiedRules.js.flow 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. // @flow strict
  2. // Spec Section: "Executable Definitions"
  3. import { ExecutableDefinitionsRule } from './rules/ExecutableDefinitionsRule';
  4. // Spec Section: "Operation Name Uniqueness"
  5. import { UniqueOperationNamesRule } from './rules/UniqueOperationNamesRule';
  6. // Spec Section: "Lone Anonymous Operation"
  7. import { LoneAnonymousOperationRule } from './rules/LoneAnonymousOperationRule';
  8. // Spec Section: "Subscriptions with Single Root Field"
  9. import { SingleFieldSubscriptionsRule } from './rules/SingleFieldSubscriptionsRule';
  10. // Spec Section: "Fragment Spread Type Existence"
  11. import { KnownTypeNamesRule } from './rules/KnownTypeNamesRule';
  12. // Spec Section: "Fragments on Composite Types"
  13. import { FragmentsOnCompositeTypesRule } from './rules/FragmentsOnCompositeTypesRule';
  14. // Spec Section: "Variables are Input Types"
  15. import { VariablesAreInputTypesRule } from './rules/VariablesAreInputTypesRule';
  16. // Spec Section: "Leaf Field Selections"
  17. import { ScalarLeafsRule } from './rules/ScalarLeafsRule';
  18. // Spec Section: "Field Selections on Objects, Interfaces, and Unions Types"
  19. import { FieldsOnCorrectTypeRule } from './rules/FieldsOnCorrectTypeRule';
  20. // Spec Section: "Fragment Name Uniqueness"
  21. import { UniqueFragmentNamesRule } from './rules/UniqueFragmentNamesRule';
  22. // Spec Section: "Fragment spread target defined"
  23. import { KnownFragmentNamesRule } from './rules/KnownFragmentNamesRule';
  24. // Spec Section: "Fragments must be used"
  25. import { NoUnusedFragmentsRule } from './rules/NoUnusedFragmentsRule';
  26. // Spec Section: "Fragment spread is possible"
  27. import { PossibleFragmentSpreadsRule } from './rules/PossibleFragmentSpreadsRule';
  28. // Spec Section: "Fragments must not form cycles"
  29. import { NoFragmentCyclesRule } from './rules/NoFragmentCyclesRule';
  30. // Spec Section: "Variable Uniqueness"
  31. import { UniqueVariableNamesRule } from './rules/UniqueVariableNamesRule';
  32. // Spec Section: "All Variable Used Defined"
  33. import { NoUndefinedVariablesRule } from './rules/NoUndefinedVariablesRule';
  34. // Spec Section: "All Variables Used"
  35. import { NoUnusedVariablesRule } from './rules/NoUnusedVariablesRule';
  36. // Spec Section: "Directives Are Defined"
  37. import { KnownDirectivesRule } from './rules/KnownDirectivesRule';
  38. // Spec Section: "Directives Are Unique Per Location"
  39. import { UniqueDirectivesPerLocationRule } from './rules/UniqueDirectivesPerLocationRule';
  40. // Spec Section: "Argument Names"
  41. import {
  42. KnownArgumentNamesRule,
  43. KnownArgumentNamesOnDirectivesRule,
  44. } from './rules/KnownArgumentNamesRule';
  45. // Spec Section: "Argument Uniqueness"
  46. import { UniqueArgumentNamesRule } from './rules/UniqueArgumentNamesRule';
  47. // Spec Section: "Value Type Correctness"
  48. import { ValuesOfCorrectTypeRule } from './rules/ValuesOfCorrectTypeRule';
  49. // Spec Section: "Argument Optionality"
  50. import {
  51. ProvidedRequiredArgumentsRule,
  52. ProvidedRequiredArgumentsOnDirectivesRule,
  53. } from './rules/ProvidedRequiredArgumentsRule';
  54. // Spec Section: "All Variable Usages Are Allowed"
  55. import { VariablesInAllowedPositionRule } from './rules/VariablesInAllowedPositionRule';
  56. // Spec Section: "Field Selection Merging"
  57. import { OverlappingFieldsCanBeMergedRule } from './rules/OverlappingFieldsCanBeMergedRule';
  58. // Spec Section: "Input Object Field Uniqueness"
  59. import { UniqueInputFieldNamesRule } from './rules/UniqueInputFieldNamesRule';
  60. // SDL-specific validation rules
  61. import { LoneSchemaDefinitionRule } from './rules/LoneSchemaDefinitionRule';
  62. import { UniqueOperationTypesRule } from './rules/UniqueOperationTypesRule';
  63. import { UniqueTypeNamesRule } from './rules/UniqueTypeNamesRule';
  64. import { UniqueEnumValueNamesRule } from './rules/UniqueEnumValueNamesRule';
  65. import { UniqueFieldDefinitionNamesRule } from './rules/UniqueFieldDefinitionNamesRule';
  66. import { UniqueDirectiveNamesRule } from './rules/UniqueDirectiveNamesRule';
  67. import { PossibleTypeExtensionsRule } from './rules/PossibleTypeExtensionsRule';
  68. /**
  69. * This set includes all validation rules defined by the GraphQL spec.
  70. *
  71. * The order of the rules in this list has been adjusted to lead to the
  72. * most clear output when encountering multiple validation errors.
  73. */
  74. export const specifiedRules = Object.freeze([
  75. ExecutableDefinitionsRule,
  76. UniqueOperationNamesRule,
  77. LoneAnonymousOperationRule,
  78. SingleFieldSubscriptionsRule,
  79. KnownTypeNamesRule,
  80. FragmentsOnCompositeTypesRule,
  81. VariablesAreInputTypesRule,
  82. ScalarLeafsRule,
  83. FieldsOnCorrectTypeRule,
  84. UniqueFragmentNamesRule,
  85. KnownFragmentNamesRule,
  86. NoUnusedFragmentsRule,
  87. PossibleFragmentSpreadsRule,
  88. NoFragmentCyclesRule,
  89. UniqueVariableNamesRule,
  90. NoUndefinedVariablesRule,
  91. NoUnusedVariablesRule,
  92. KnownDirectivesRule,
  93. UniqueDirectivesPerLocationRule,
  94. KnownArgumentNamesRule,
  95. UniqueArgumentNamesRule,
  96. ValuesOfCorrectTypeRule,
  97. ProvidedRequiredArgumentsRule,
  98. VariablesInAllowedPositionRule,
  99. OverlappingFieldsCanBeMergedRule,
  100. UniqueInputFieldNamesRule,
  101. ]);
  102. /**
  103. * @internal
  104. */
  105. export const specifiedSDLRules = Object.freeze([
  106. LoneSchemaDefinitionRule,
  107. UniqueOperationTypesRule,
  108. UniqueTypeNamesRule,
  109. UniqueEnumValueNamesRule,
  110. UniqueFieldDefinitionNamesRule,
  111. UniqueDirectiveNamesRule,
  112. KnownTypeNamesRule,
  113. KnownDirectivesRule,
  114. UniqueDirectivesPerLocationRule,
  115. PossibleTypeExtensionsRule,
  116. KnownArgumentNamesOnDirectivesRule,
  117. UniqueArgumentNamesRule,
  118. UniqueInputFieldNamesRule,
  119. ProvidedRequiredArgumentsOnDirectivesRule,
  120. ]);