specifiedRules.js.flow 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // @flow strict
  2. // Spec Section: "Executable Definitions"
  3. import { ExecutableDefinitions } from './rules/ExecutableDefinitions';
  4. // Spec Section: "Operation Name Uniqueness"
  5. import { UniqueOperationNames } from './rules/UniqueOperationNames';
  6. // Spec Section: "Lone Anonymous Operation"
  7. import { LoneAnonymousOperation } from './rules/LoneAnonymousOperation';
  8. // Spec Section: "Subscriptions with Single Root Field"
  9. import { SingleFieldSubscriptions } from './rules/SingleFieldSubscriptions';
  10. // Spec Section: "Fragment Spread Type Existence"
  11. import { KnownTypeNames } from './rules/KnownTypeNames';
  12. // Spec Section: "Fragments on Composite Types"
  13. import { FragmentsOnCompositeTypes } from './rules/FragmentsOnCompositeTypes';
  14. // Spec Section: "Variables are Input Types"
  15. import { VariablesAreInputTypes } from './rules/VariablesAreInputTypes';
  16. // Spec Section: "Leaf Field Selections"
  17. import { ScalarLeafs } from './rules/ScalarLeafs';
  18. // Spec Section: "Field Selections on Objects, Interfaces, and Unions Types"
  19. import { FieldsOnCorrectType } from './rules/FieldsOnCorrectType';
  20. // Spec Section: "Fragment Name Uniqueness"
  21. import { UniqueFragmentNames } from './rules/UniqueFragmentNames';
  22. // Spec Section: "Fragment spread target defined"
  23. import { KnownFragmentNames } from './rules/KnownFragmentNames';
  24. // Spec Section: "Fragments must be used"
  25. import { NoUnusedFragments } from './rules/NoUnusedFragments';
  26. // Spec Section: "Fragment spread is possible"
  27. import { PossibleFragmentSpreads } from './rules/PossibleFragmentSpreads';
  28. // Spec Section: "Fragments must not form cycles"
  29. import { NoFragmentCycles } from './rules/NoFragmentCycles';
  30. // Spec Section: "Variable Uniqueness"
  31. import { UniqueVariableNames } from './rules/UniqueVariableNames';
  32. // Spec Section: "All Variable Used Defined"
  33. import { NoUndefinedVariables } from './rules/NoUndefinedVariables';
  34. // Spec Section: "All Variables Used"
  35. import { NoUnusedVariables } from './rules/NoUnusedVariables';
  36. // Spec Section: "Directives Are Defined"
  37. import { KnownDirectives } from './rules/KnownDirectives';
  38. // Spec Section: "Directives Are Unique Per Location"
  39. import { UniqueDirectivesPerLocation } from './rules/UniqueDirectivesPerLocation';
  40. // Spec Section: "Argument Names"
  41. import {
  42. KnownArgumentNames,
  43. KnownArgumentNamesOnDirectives, // @internal
  44. } from './rules/KnownArgumentNames';
  45. // Spec Section: "Argument Uniqueness"
  46. import { UniqueArgumentNames } from './rules/UniqueArgumentNames';
  47. // Spec Section: "Value Type Correctness"
  48. import { ValuesOfCorrectType } from './rules/ValuesOfCorrectType';
  49. // Spec Section: "Argument Optionality"
  50. import {
  51. ProvidedRequiredArguments,
  52. ProvidedRequiredArgumentsOnDirectives, // @internal
  53. } from './rules/ProvidedRequiredArguments';
  54. // Spec Section: "All Variable Usages Are Allowed"
  55. import { VariablesInAllowedPosition } from './rules/VariablesInAllowedPosition';
  56. // Spec Section: "Field Selection Merging"
  57. import { OverlappingFieldsCanBeMerged } from './rules/OverlappingFieldsCanBeMerged';
  58. // Spec Section: "Input Object Field Uniqueness"
  59. import { UniqueInputFieldNames } from './rules/UniqueInputFieldNames';
  60. /**
  61. * This set includes all validation rules defined by the GraphQL spec.
  62. *
  63. * The order of the rules in this list has been adjusted to lead to the
  64. * most clear output when encountering multiple validation errors.
  65. */
  66. export const specifiedRules = Object.freeze([
  67. ExecutableDefinitions,
  68. UniqueOperationNames,
  69. LoneAnonymousOperation,
  70. SingleFieldSubscriptions,
  71. KnownTypeNames,
  72. FragmentsOnCompositeTypes,
  73. VariablesAreInputTypes,
  74. ScalarLeafs,
  75. FieldsOnCorrectType,
  76. UniqueFragmentNames,
  77. KnownFragmentNames,
  78. NoUnusedFragments,
  79. PossibleFragmentSpreads,
  80. NoFragmentCycles,
  81. UniqueVariableNames,
  82. NoUndefinedVariables,
  83. NoUnusedVariables,
  84. KnownDirectives,
  85. UniqueDirectivesPerLocation,
  86. KnownArgumentNames,
  87. UniqueArgumentNames,
  88. ValuesOfCorrectType,
  89. ProvidedRequiredArguments,
  90. VariablesInAllowedPosition,
  91. OverlappingFieldsCanBeMerged,
  92. UniqueInputFieldNames,
  93. ]);
  94. import { LoneSchemaDefinition } from './rules/LoneSchemaDefinition';
  95. import { UniqueOperationTypes } from './rules/UniqueOperationTypes';
  96. import { UniqueTypeNames } from './rules/UniqueTypeNames';
  97. import { UniqueEnumValueNames } from './rules/UniqueEnumValueNames';
  98. import { UniqueFieldDefinitionNames } from './rules/UniqueFieldDefinitionNames';
  99. import { UniqueDirectiveNames } from './rules/UniqueDirectiveNames';
  100. import { PossibleTypeExtensions } from './rules/PossibleTypeExtensions';
  101. // @internal
  102. export const specifiedSDLRules = Object.freeze([
  103. LoneSchemaDefinition,
  104. UniqueOperationTypes,
  105. UniqueTypeNames,
  106. UniqueEnumValueNames,
  107. UniqueFieldDefinitionNames,
  108. UniqueDirectiveNames,
  109. KnownTypeNames,
  110. KnownDirectives,
  111. UniqueDirectivesPerLocation,
  112. PossibleTypeExtensions,
  113. KnownArgumentNamesOnDirectives,
  114. UniqueArgumentNames,
  115. UniqueInputFieldNames,
  116. ProvidedRequiredArgumentsOnDirectives,
  117. ]);