@theguild/federation-composition 0.0.0-alpha-20230916192321-bb37b43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (355) hide show
  1. package/LICENSE +18 -0
  2. package/cjs/compose.js +85 -0
  3. package/cjs/graphql/helpers.js +32 -0
  4. package/cjs/graphql/printer.js +248 -0
  5. package/cjs/graphql/type-node-info.js +142 -0
  6. package/cjs/index.js +22 -0
  7. package/cjs/package.json +1 -0
  8. package/cjs/specifications/federation.js +211 -0
  9. package/cjs/specifications/inaccessible.js +10 -0
  10. package/cjs/specifications/join.js +35 -0
  11. package/cjs/specifications/link.js +222 -0
  12. package/cjs/specifications/tag.js +12 -0
  13. package/cjs/subgraph/helpers.js +255 -0
  14. package/cjs/subgraph/state.js +1154 -0
  15. package/cjs/subgraph/validation/rules/elements/compose-directive.js +41 -0
  16. package/cjs/subgraph/validation/rules/elements/extends.js +34 -0
  17. package/cjs/subgraph/validation/rules/elements/external.js +57 -0
  18. package/cjs/subgraph/validation/rules/elements/field-set.js +37 -0
  19. package/cjs/subgraph/validation/rules/elements/inaccessible.js +112 -0
  20. package/cjs/subgraph/validation/rules/elements/key.js +148 -0
  21. package/cjs/subgraph/validation/rules/elements/override.js +56 -0
  22. package/cjs/subgraph/validation/rules/elements/provides.js +173 -0
  23. package/cjs/subgraph/validation/rules/elements/requires.js +119 -0
  24. package/cjs/subgraph/validation/rules/elements/shareable.js +43 -0
  25. package/cjs/subgraph/validation/rules/elements/tag.js +120 -0
  26. package/cjs/subgraph/validation/rules/known-argument-names-on-directives-rule.js +34 -0
  27. package/cjs/subgraph/validation/rules/known-directives-rule.js +105 -0
  28. package/cjs/subgraph/validation/rules/known-federation-directive-rule.js +34 -0
  29. package/cjs/subgraph/validation/rules/known-root-type-rule.js +25 -0
  30. package/cjs/subgraph/validation/rules/known-type-names-rule.js +34 -0
  31. package/cjs/subgraph/validation/rules/lone-schema-definition-rule.js +20 -0
  32. package/cjs/subgraph/validation/rules/provided-arguments-on-directives-rule.js +104 -0
  33. package/cjs/subgraph/validation/rules/provided-required-arguments-on-directives-rule.js +46 -0
  34. package/cjs/subgraph/validation/rules/query-root-type-inaccessible-rule.js +33 -0
  35. package/cjs/subgraph/validation/rules/reserved-subgraph-name-rule.js +15 -0
  36. package/cjs/subgraph/validation/rules/root-type-used-rule.js +59 -0
  37. package/cjs/subgraph/validation/rules/unique-argument-definition-names-rule.js +42 -0
  38. package/cjs/subgraph/validation/rules/unique-argument-names-rule.js +27 -0
  39. package/cjs/subgraph/validation/rules/unique-directive-names-rule.js +24 -0
  40. package/cjs/subgraph/validation/rules/unique-directives-per-location-rule.js +52 -0
  41. package/cjs/subgraph/validation/rules/unique-enum-value-names-rule.js +33 -0
  42. package/cjs/subgraph/validation/rules/unique-field-definition-names-rule.js +37 -0
  43. package/cjs/subgraph/validation/rules/unique-input-field-names-rule.js +37 -0
  44. package/cjs/subgraph/validation/rules/unique-operation-types-rule.js +29 -0
  45. package/cjs/subgraph/validation/rules/unique-type-names-rule.js +29 -0
  46. package/cjs/subgraph/validation/validate-state.js +476 -0
  47. package/cjs/subgraph/validation/validate-subgraph.js +329 -0
  48. package/cjs/subgraph/validation/validation-context.js +267 -0
  49. package/cjs/supergraph/composition/ast.js +779 -0
  50. package/cjs/supergraph/composition/common.js +7 -0
  51. package/cjs/supergraph/composition/directive.js +93 -0
  52. package/cjs/supergraph/composition/enum-type.js +132 -0
  53. package/cjs/supergraph/composition/input-object-type.js +119 -0
  54. package/cjs/supergraph/composition/interface-type.js +226 -0
  55. package/cjs/supergraph/composition/object-type.js +380 -0
  56. package/cjs/supergraph/composition/scalar-type.js +63 -0
  57. package/cjs/supergraph/composition/union-type.js +64 -0
  58. package/cjs/supergraph/composition/visitor.js +62 -0
  59. package/cjs/supergraph/state.js +249 -0
  60. package/cjs/supergraph/validation/rules/default-value-uses-inaccessible-rule.js +35 -0
  61. package/cjs/supergraph/validation/rules/directive-composition-rule.js +98 -0
  62. package/cjs/supergraph/validation/rules/enum-values-rule.js +59 -0
  63. package/cjs/supergraph/validation/rules/extension-with-base.js +31 -0
  64. package/cjs/supergraph/validation/rules/external-argument-missing-rule.js +32 -0
  65. package/cjs/supergraph/validation/rules/external-missing-on-base-rule.js +48 -0
  66. package/cjs/supergraph/validation/rules/external-type-mismatch-rule.js +52 -0
  67. package/cjs/supergraph/validation/rules/field-argument-default-mismatch-rule.js +40 -0
  68. package/cjs/supergraph/validation/rules/field-arguments-of-the-same-type-rule.js +49 -0
  69. package/cjs/supergraph/validation/rules/fields-of-the-same-type-rule.js +89 -0
  70. package/cjs/supergraph/validation/rules/input-field-default-mismatch-rule.js +40 -0
  71. package/cjs/supergraph/validation/rules/input-object-values-rule.js +25 -0
  72. package/cjs/supergraph/validation/rules/interface-key-missing-implementation-type.js +46 -0
  73. package/cjs/supergraph/validation/rules/invalid-field-sharing-rule.js +45 -0
  74. package/cjs/supergraph/validation/rules/only-inaccessible-children-rule.js +40 -0
  75. package/cjs/supergraph/validation/rules/override-source-has-override.js +36 -0
  76. package/cjs/supergraph/validation/rules/referenced-inaccessible-rule.js +44 -0
  77. package/cjs/supergraph/validation/rules/required-argument-missing-in-some-subgraph-rule.js +32 -0
  78. package/cjs/supergraph/validation/rules/required-input-field-missing-in-some-subgraph-rule.js +32 -0
  79. package/cjs/supergraph/validation/rules/required-query-rule.js +14 -0
  80. package/cjs/supergraph/validation/rules/satisfiablity-rule.js +866 -0
  81. package/cjs/supergraph/validation/rules/subgraph-name-rule.js +18 -0
  82. package/cjs/supergraph/validation/rules/types-of-the-same-kind-rule.js +54 -0
  83. package/cjs/supergraph/validation/validate-supergraph.js +77 -0
  84. package/cjs/supergraph/validation/validation-context.js +25 -0
  85. package/cjs/types.js +0 -0
  86. package/cjs/utils/dependency-graph.js +227 -0
  87. package/cjs/utils/format.js +27 -0
  88. package/cjs/utils/helpers.js +7 -0
  89. package/cjs/utils/state.js +23 -0
  90. package/cjs/validate.js +117 -0
  91. package/esm/compose.js +78 -0
  92. package/esm/graphql/helpers.js +27 -0
  93. package/esm/graphql/printer.js +244 -0
  94. package/esm/graphql/type-node-info.js +137 -0
  95. package/esm/index.js +4 -0
  96. package/esm/specifications/federation.js +204 -0
  97. package/esm/specifications/inaccessible.js +7 -0
  98. package/esm/specifications/join.js +32 -0
  99. package/esm/specifications/link.js +210 -0
  100. package/esm/specifications/tag.js +9 -0
  101. package/esm/subgraph/helpers.js +245 -0
  102. package/esm/subgraph/state.js +1148 -0
  103. package/esm/subgraph/validation/rules/elements/compose-directive.js +37 -0
  104. package/esm/subgraph/validation/rules/elements/extends.js +30 -0
  105. package/esm/subgraph/validation/rules/elements/external.js +53 -0
  106. package/esm/subgraph/validation/rules/elements/field-set.js +33 -0
  107. package/esm/subgraph/validation/rules/elements/inaccessible.js +108 -0
  108. package/esm/subgraph/validation/rules/elements/key.js +144 -0
  109. package/esm/subgraph/validation/rules/elements/override.js +52 -0
  110. package/esm/subgraph/validation/rules/elements/provides.js +169 -0
  111. package/esm/subgraph/validation/rules/elements/requires.js +115 -0
  112. package/esm/subgraph/validation/rules/elements/shareable.js +39 -0
  113. package/esm/subgraph/validation/rules/elements/tag.js +116 -0
  114. package/esm/subgraph/validation/rules/known-argument-names-on-directives-rule.js +30 -0
  115. package/esm/subgraph/validation/rules/known-directives-rule.js +101 -0
  116. package/esm/subgraph/validation/rules/known-federation-directive-rule.js +30 -0
  117. package/esm/subgraph/validation/rules/known-root-type-rule.js +21 -0
  118. package/esm/subgraph/validation/rules/known-type-names-rule.js +30 -0
  119. package/esm/subgraph/validation/rules/lone-schema-definition-rule.js +16 -0
  120. package/esm/subgraph/validation/rules/provided-arguments-on-directives-rule.js +100 -0
  121. package/esm/subgraph/validation/rules/provided-required-arguments-on-directives-rule.js +42 -0
  122. package/esm/subgraph/validation/rules/query-root-type-inaccessible-rule.js +29 -0
  123. package/esm/subgraph/validation/rules/reserved-subgraph-name-rule.js +11 -0
  124. package/esm/subgraph/validation/rules/root-type-used-rule.js +55 -0
  125. package/esm/subgraph/validation/rules/unique-argument-definition-names-rule.js +38 -0
  126. package/esm/subgraph/validation/rules/unique-argument-names-rule.js +23 -0
  127. package/esm/subgraph/validation/rules/unique-directive-names-rule.js +20 -0
  128. package/esm/subgraph/validation/rules/unique-directives-per-location-rule.js +48 -0
  129. package/esm/subgraph/validation/rules/unique-enum-value-names-rule.js +29 -0
  130. package/esm/subgraph/validation/rules/unique-field-definition-names-rule.js +33 -0
  131. package/esm/subgraph/validation/rules/unique-input-field-names-rule.js +33 -0
  132. package/esm/subgraph/validation/rules/unique-operation-types-rule.js +25 -0
  133. package/esm/subgraph/validation/rules/unique-type-names-rule.js +25 -0
  134. package/esm/subgraph/validation/validate-state.js +463 -0
  135. package/esm/subgraph/validation/validate-subgraph.js +323 -0
  136. package/esm/subgraph/validation/validation-context.js +262 -0
  137. package/esm/supergraph/composition/ast.js +765 -0
  138. package/esm/supergraph/composition/common.js +3 -0
  139. package/esm/supergraph/composition/directive.js +89 -0
  140. package/esm/supergraph/composition/enum-type.js +128 -0
  141. package/esm/supergraph/composition/input-object-type.js +115 -0
  142. package/esm/supergraph/composition/interface-type.js +222 -0
  143. package/esm/supergraph/composition/object-type.js +375 -0
  144. package/esm/supergraph/composition/scalar-type.js +59 -0
  145. package/esm/supergraph/composition/union-type.js +60 -0
  146. package/esm/supergraph/composition/visitor.js +58 -0
  147. package/esm/supergraph/state.js +245 -0
  148. package/esm/supergraph/validation/rules/default-value-uses-inaccessible-rule.js +31 -0
  149. package/esm/supergraph/validation/rules/directive-composition-rule.js +94 -0
  150. package/esm/supergraph/validation/rules/enum-values-rule.js +55 -0
  151. package/esm/supergraph/validation/rules/extension-with-base.js +27 -0
  152. package/esm/supergraph/validation/rules/external-argument-missing-rule.js +28 -0
  153. package/esm/supergraph/validation/rules/external-missing-on-base-rule.js +44 -0
  154. package/esm/supergraph/validation/rules/external-type-mismatch-rule.js +48 -0
  155. package/esm/supergraph/validation/rules/field-argument-default-mismatch-rule.js +36 -0
  156. package/esm/supergraph/validation/rules/field-arguments-of-the-same-type-rule.js +45 -0
  157. package/esm/supergraph/validation/rules/fields-of-the-same-type-rule.js +85 -0
  158. package/esm/supergraph/validation/rules/input-field-default-mismatch-rule.js +36 -0
  159. package/esm/supergraph/validation/rules/input-object-values-rule.js +21 -0
  160. package/esm/supergraph/validation/rules/interface-key-missing-implementation-type.js +42 -0
  161. package/esm/supergraph/validation/rules/invalid-field-sharing-rule.js +41 -0
  162. package/esm/supergraph/validation/rules/only-inaccessible-children-rule.js +36 -0
  163. package/esm/supergraph/validation/rules/override-source-has-override.js +32 -0
  164. package/esm/supergraph/validation/rules/referenced-inaccessible-rule.js +40 -0
  165. package/esm/supergraph/validation/rules/required-argument-missing-in-some-subgraph-rule.js +28 -0
  166. package/esm/supergraph/validation/rules/required-input-field-missing-in-some-subgraph-rule.js +28 -0
  167. package/esm/supergraph/validation/rules/required-query-rule.js +10 -0
  168. package/esm/supergraph/validation/rules/satisfiablity-rule.js +862 -0
  169. package/esm/supergraph/validation/rules/subgraph-name-rule.js +14 -0
  170. package/esm/supergraph/validation/rules/types-of-the-same-kind-rule.js +50 -0
  171. package/esm/supergraph/validation/validate-supergraph.js +73 -0
  172. package/esm/supergraph/validation/validation-context.js +21 -0
  173. package/esm/types.js +0 -0
  174. package/esm/utils/dependency-graph.js +222 -0
  175. package/esm/utils/format.js +23 -0
  176. package/esm/utils/helpers.js +3 -0
  177. package/esm/utils/state.js +15 -0
  178. package/esm/validate.js +113 -0
  179. package/package.json +46 -0
  180. package/typings/compose.d.cts +16 -0
  181. package/typings/compose.d.ts +16 -0
  182. package/typings/graphql/helpers.d.cts +4 -0
  183. package/typings/graphql/helpers.d.ts +4 -0
  184. package/typings/graphql/printer.d.cts +3 -0
  185. package/typings/graphql/printer.d.ts +3 -0
  186. package/typings/graphql/type-node-info.d.cts +19 -0
  187. package/typings/graphql/type-node-info.d.ts +19 -0
  188. package/typings/index.d.cts +5 -0
  189. package/typings/index.d.ts +5 -0
  190. package/typings/specifications/federation.d.cts +45 -0
  191. package/typings/specifications/federation.d.ts +45 -0
  192. package/typings/specifications/inaccessible.d.cts +4 -0
  193. package/typings/specifications/inaccessible.d.ts +4 -0
  194. package/typings/specifications/join.d.cts +2 -0
  195. package/typings/specifications/join.d.ts +2 -0
  196. package/typings/specifications/link.d.cts +61 -0
  197. package/typings/specifications/link.d.ts +61 -0
  198. package/typings/specifications/tag.d.cts +4 -0
  199. package/typings/specifications/tag.d.ts +4 -0
  200. package/typings/subgraph/helpers.d.cts +44 -0
  201. package/typings/subgraph/helpers.d.ts +44 -0
  202. package/typings/subgraph/state.d.cts +322 -0
  203. package/typings/subgraph/state.d.ts +322 -0
  204. package/typings/subgraph/validation/rules/elements/compose-directive.d.cts +4 -0
  205. package/typings/subgraph/validation/rules/elements/compose-directive.d.ts +4 -0
  206. package/typings/subgraph/validation/rules/elements/extends.d.cts +4 -0
  207. package/typings/subgraph/validation/rules/elements/extends.d.ts +4 -0
  208. package/typings/subgraph/validation/rules/elements/external.d.cts +4 -0
  209. package/typings/subgraph/validation/rules/elements/external.d.ts +4 -0
  210. package/typings/subgraph/validation/rules/elements/field-set.d.cts +4 -0
  211. package/typings/subgraph/validation/rules/elements/field-set.d.ts +4 -0
  212. package/typings/subgraph/validation/rules/elements/inaccessible.d.cts +4 -0
  213. package/typings/subgraph/validation/rules/elements/inaccessible.d.ts +4 -0
  214. package/typings/subgraph/validation/rules/elements/key.d.cts +4 -0
  215. package/typings/subgraph/validation/rules/elements/key.d.ts +4 -0
  216. package/typings/subgraph/validation/rules/elements/override.d.cts +4 -0
  217. package/typings/subgraph/validation/rules/elements/override.d.ts +4 -0
  218. package/typings/subgraph/validation/rules/elements/provides.d.cts +4 -0
  219. package/typings/subgraph/validation/rules/elements/provides.d.ts +4 -0
  220. package/typings/subgraph/validation/rules/elements/requires.d.cts +4 -0
  221. package/typings/subgraph/validation/rules/elements/requires.d.ts +4 -0
  222. package/typings/subgraph/validation/rules/elements/shareable.d.cts +4 -0
  223. package/typings/subgraph/validation/rules/elements/shareable.d.ts +4 -0
  224. package/typings/subgraph/validation/rules/elements/tag.d.cts +4 -0
  225. package/typings/subgraph/validation/rules/elements/tag.d.ts +4 -0
  226. package/typings/subgraph/validation/rules/known-argument-names-on-directives-rule.d.cts +6 -0
  227. package/typings/subgraph/validation/rules/known-argument-names-on-directives-rule.d.ts +6 -0
  228. package/typings/subgraph/validation/rules/known-directives-rule.d.cts +6 -0
  229. package/typings/subgraph/validation/rules/known-directives-rule.d.ts +6 -0
  230. package/typings/subgraph/validation/rules/known-federation-directive-rule.d.cts +4 -0
  231. package/typings/subgraph/validation/rules/known-federation-directive-rule.d.ts +4 -0
  232. package/typings/subgraph/validation/rules/known-root-type-rule.d.cts +4 -0
  233. package/typings/subgraph/validation/rules/known-root-type-rule.d.ts +4 -0
  234. package/typings/subgraph/validation/rules/known-type-names-rule.d.cts +4 -0
  235. package/typings/subgraph/validation/rules/known-type-names-rule.d.ts +4 -0
  236. package/typings/subgraph/validation/rules/lone-schema-definition-rule.d.cts +5 -0
  237. package/typings/subgraph/validation/rules/lone-schema-definition-rule.d.ts +5 -0
  238. package/typings/subgraph/validation/rules/provided-arguments-on-directives-rule.d.cts +4 -0
  239. package/typings/subgraph/validation/rules/provided-arguments-on-directives-rule.d.ts +4 -0
  240. package/typings/subgraph/validation/rules/provided-required-arguments-on-directives-rule.d.cts +4 -0
  241. package/typings/subgraph/validation/rules/provided-required-arguments-on-directives-rule.d.ts +4 -0
  242. package/typings/subgraph/validation/rules/query-root-type-inaccessible-rule.d.cts +4 -0
  243. package/typings/subgraph/validation/rules/query-root-type-inaccessible-rule.d.ts +4 -0
  244. package/typings/subgraph/validation/rules/reserved-subgraph-name-rule.d.cts +4 -0
  245. package/typings/subgraph/validation/rules/reserved-subgraph-name-rule.d.ts +4 -0
  246. package/typings/subgraph/validation/rules/root-type-used-rule.d.cts +4 -0
  247. package/typings/subgraph/validation/rules/root-type-used-rule.d.ts +4 -0
  248. package/typings/subgraph/validation/rules/unique-argument-definition-names-rule.d.cts +5 -0
  249. package/typings/subgraph/validation/rules/unique-argument-definition-names-rule.d.ts +5 -0
  250. package/typings/subgraph/validation/rules/unique-argument-names-rule.d.cts +5 -0
  251. package/typings/subgraph/validation/rules/unique-argument-names-rule.d.ts +5 -0
  252. package/typings/subgraph/validation/rules/unique-directive-names-rule.d.cts +5 -0
  253. package/typings/subgraph/validation/rules/unique-directive-names-rule.d.ts +5 -0
  254. package/typings/subgraph/validation/rules/unique-directives-per-location-rule.d.cts +6 -0
  255. package/typings/subgraph/validation/rules/unique-directives-per-location-rule.d.ts +6 -0
  256. package/typings/subgraph/validation/rules/unique-enum-value-names-rule.d.cts +5 -0
  257. package/typings/subgraph/validation/rules/unique-enum-value-names-rule.d.ts +5 -0
  258. package/typings/subgraph/validation/rules/unique-field-definition-names-rule.d.cts +5 -0
  259. package/typings/subgraph/validation/rules/unique-field-definition-names-rule.d.ts +5 -0
  260. package/typings/subgraph/validation/rules/unique-input-field-names-rule.d.cts +5 -0
  261. package/typings/subgraph/validation/rules/unique-input-field-names-rule.d.ts +5 -0
  262. package/typings/subgraph/validation/rules/unique-operation-types-rule.d.cts +5 -0
  263. package/typings/subgraph/validation/rules/unique-operation-types-rule.d.ts +5 -0
  264. package/typings/subgraph/validation/rules/unique-type-names-rule.d.cts +5 -0
  265. package/typings/subgraph/validation/rules/unique-type-names-rule.d.ts +5 -0
  266. package/typings/subgraph/validation/validate-state.d.cts +13 -0
  267. package/typings/subgraph/validation/validate-state.d.ts +13 -0
  268. package/typings/subgraph/validation/validate-subgraph.d.cts +43 -0
  269. package/typings/subgraph/validation/validate-subgraph.d.ts +43 -0
  270. package/typings/subgraph/validation/validation-context.d.cts +182 -0
  271. package/typings/subgraph/validation/validation-context.d.ts +182 -0
  272. package/typings/supergraph/composition/ast.d.cts +216 -0
  273. package/typings/supergraph/composition/ast.d.ts +216 -0
  274. package/typings/supergraph/composition/common.d.cts +19 -0
  275. package/typings/supergraph/composition/common.d.ts +19 -0
  276. package/typings/supergraph/composition/directive.d.cts +32 -0
  277. package/typings/supergraph/composition/directive.d.ts +32 -0
  278. package/typings/supergraph/composition/enum-type.d.cts +32 -0
  279. package/typings/supergraph/composition/enum-type.d.ts +32 -0
  280. package/typings/supergraph/composition/input-object-type.d.cts +32 -0
  281. package/typings/supergraph/composition/input-object-type.d.ts +32 -0
  282. package/typings/supergraph/composition/interface-type.d.cts +61 -0
  283. package/typings/supergraph/composition/interface-type.d.ts +61 -0
  284. package/typings/supergraph/composition/object-type.d.cts +79 -0
  285. package/typings/supergraph/composition/object-type.d.ts +79 -0
  286. package/typings/supergraph/composition/scalar-type.d.cts +20 -0
  287. package/typings/supergraph/composition/scalar-type.d.ts +20 -0
  288. package/typings/supergraph/composition/union-type.d.cts +17 -0
  289. package/typings/supergraph/composition/union-type.d.ts +17 -0
  290. package/typings/supergraph/composition/visitor.d.cts +18 -0
  291. package/typings/supergraph/composition/visitor.d.ts +18 -0
  292. package/typings/supergraph/state.d.cts +51 -0
  293. package/typings/supergraph/state.d.ts +51 -0
  294. package/typings/supergraph/validation/rules/default-value-uses-inaccessible-rule.d.cts +5 -0
  295. package/typings/supergraph/validation/rules/default-value-uses-inaccessible-rule.d.ts +5 -0
  296. package/typings/supergraph/validation/rules/directive-composition-rule.d.cts +5 -0
  297. package/typings/supergraph/validation/rules/directive-composition-rule.d.ts +5 -0
  298. package/typings/supergraph/validation/rules/enum-values-rule.d.cts +4 -0
  299. package/typings/supergraph/validation/rules/enum-values-rule.d.ts +4 -0
  300. package/typings/supergraph/validation/rules/extension-with-base.d.cts +4 -0
  301. package/typings/supergraph/validation/rules/extension-with-base.d.ts +4 -0
  302. package/typings/supergraph/validation/rules/external-argument-missing-rule.d.cts +4 -0
  303. package/typings/supergraph/validation/rules/external-argument-missing-rule.d.ts +4 -0
  304. package/typings/supergraph/validation/rules/external-missing-on-base-rule.d.cts +4 -0
  305. package/typings/supergraph/validation/rules/external-missing-on-base-rule.d.ts +4 -0
  306. package/typings/supergraph/validation/rules/external-type-mismatch-rule.d.cts +4 -0
  307. package/typings/supergraph/validation/rules/external-type-mismatch-rule.d.ts +4 -0
  308. package/typings/supergraph/validation/rules/field-argument-default-mismatch-rule.d.cts +4 -0
  309. package/typings/supergraph/validation/rules/field-argument-default-mismatch-rule.d.ts +4 -0
  310. package/typings/supergraph/validation/rules/field-arguments-of-the-same-type-rule.d.cts +4 -0
  311. package/typings/supergraph/validation/rules/field-arguments-of-the-same-type-rule.d.ts +4 -0
  312. package/typings/supergraph/validation/rules/fields-of-the-same-type-rule.d.cts +4 -0
  313. package/typings/supergraph/validation/rules/fields-of-the-same-type-rule.d.ts +4 -0
  314. package/typings/supergraph/validation/rules/input-field-default-mismatch-rule.d.cts +4 -0
  315. package/typings/supergraph/validation/rules/input-field-default-mismatch-rule.d.ts +4 -0
  316. package/typings/supergraph/validation/rules/input-object-values-rule.d.cts +4 -0
  317. package/typings/supergraph/validation/rules/input-object-values-rule.d.ts +4 -0
  318. package/typings/supergraph/validation/rules/interface-key-missing-implementation-type.d.cts +4 -0
  319. package/typings/supergraph/validation/rules/interface-key-missing-implementation-type.d.ts +4 -0
  320. package/typings/supergraph/validation/rules/invalid-field-sharing-rule.d.cts +4 -0
  321. package/typings/supergraph/validation/rules/invalid-field-sharing-rule.d.ts +4 -0
  322. package/typings/supergraph/validation/rules/only-inaccessible-children-rule.d.cts +4 -0
  323. package/typings/supergraph/validation/rules/only-inaccessible-children-rule.d.ts +4 -0
  324. package/typings/supergraph/validation/rules/override-source-has-override.d.cts +4 -0
  325. package/typings/supergraph/validation/rules/override-source-has-override.d.ts +4 -0
  326. package/typings/supergraph/validation/rules/referenced-inaccessible-rule.d.cts +5 -0
  327. package/typings/supergraph/validation/rules/referenced-inaccessible-rule.d.ts +5 -0
  328. package/typings/supergraph/validation/rules/required-argument-missing-in-some-subgraph-rule.d.cts +4 -0
  329. package/typings/supergraph/validation/rules/required-argument-missing-in-some-subgraph-rule.d.ts +4 -0
  330. package/typings/supergraph/validation/rules/required-input-field-missing-in-some-subgraph-rule.d.cts +4 -0
  331. package/typings/supergraph/validation/rules/required-input-field-missing-in-some-subgraph-rule.d.ts +4 -0
  332. package/typings/supergraph/validation/rules/required-query-rule.d.cts +3 -0
  333. package/typings/supergraph/validation/rules/required-query-rule.d.ts +3 -0
  334. package/typings/supergraph/validation/rules/satisfiablity-rule.d.cts +5 -0
  335. package/typings/supergraph/validation/rules/satisfiablity-rule.d.ts +5 -0
  336. package/typings/supergraph/validation/rules/subgraph-name-rule.d.cts +3 -0
  337. package/typings/supergraph/validation/rules/subgraph-name-rule.d.ts +3 -0
  338. package/typings/supergraph/validation/rules/types-of-the-same-kind-rule.d.cts +3 -0
  339. package/typings/supergraph/validation/rules/types-of-the-same-kind-rule.d.ts +3 -0
  340. package/typings/supergraph/validation/validate-supergraph.d.cts +6 -0
  341. package/typings/supergraph/validation/validate-supergraph.d.ts +6 -0
  342. package/typings/supergraph/validation/validation-context.d.cts +10 -0
  343. package/typings/supergraph/validation/validation-context.d.ts +10 -0
  344. package/typings/types.d.cts +7 -0
  345. package/typings/types.d.ts +7 -0
  346. package/typings/utils/dependency-graph.d.cts +31 -0
  347. package/typings/utils/dependency-graph.d.ts +31 -0
  348. package/typings/utils/format.d.cts +2 -0
  349. package/typings/utils/format.d.ts +2 -0
  350. package/typings/utils/helpers.d.cts +2 -0
  351. package/typings/utils/helpers.d.ts +2 -0
  352. package/typings/utils/state.d.cts +6 -0
  353. package/typings/utils/state.d.ts +6 -0
  354. package/typings/validate.d.cts +37 -0
  355. package/typings/validate.d.ts +37 -0
@@ -0,0 +1,29 @@
1
+ import { GraphQLError, OperationTypeNode } from 'graphql';
2
+ export function QueryRootTypeInaccessibleRule(context) {
3
+ let rootTypeName = 'Query';
4
+ return {
5
+ SchemaDefinition(node) {
6
+ const nonQueryType = node.operationTypes?.find(operationType => operationType.operation === OperationTypeNode.QUERY &&
7
+ operationType.type.name.value !== 'Query');
8
+ if (nonQueryType) {
9
+ rootTypeName = nonQueryType.type.name.value;
10
+ }
11
+ },
12
+ SchemaExtension(node) {
13
+ const nonQueryType = node.operationTypes?.find(operationType => operationType.operation === OperationTypeNode.QUERY &&
14
+ operationType.type.name.value !== 'Query');
15
+ if (nonQueryType) {
16
+ rootTypeName = nonQueryType.type.name.value;
17
+ }
18
+ },
19
+ ObjectTypeDefinition(node) {
20
+ const name = node.name.value;
21
+ if (name !== rootTypeName) {
22
+ return;
23
+ }
24
+ if (node.directives?.some(directive => context.isAvailableFederationDirective('inaccessible', directive))) {
25
+ context.reportError(new GraphQLError(`Type "Query" is @inaccessible but is the root query type, which must be in the API schema.`, { nodes: node, extensions: { code: 'QUERY_ROOT_TYPE_INACCESSIBLE' } }));
26
+ }
27
+ },
28
+ };
29
+ }
@@ -0,0 +1,11 @@
1
+ import { GraphQLError } from 'graphql';
2
+ export function ReservedSubgraphNameRule(context) {
3
+ if (context.getSubgraphName() === '_') {
4
+ context.reportError(new GraphQLError(`Invalid name _ for a subgraph: this name is reserved`, {
5
+ extensions: {
6
+ code: 'INVALID_SUBGRAPH_NAME',
7
+ },
8
+ }));
9
+ }
10
+ return {};
11
+ }
@@ -0,0 +1,55 @@
1
+ import { GraphQLError, isTypeDefinitionNode, OperationTypeNode, } from 'graphql';
2
+ function findDefaultRootTypes(definitions) {
3
+ const foundRootTypes = {
4
+ query: null,
5
+ mutation: null,
6
+ subscription: null,
7
+ };
8
+ const found = new Set();
9
+ for (const definition of definitions) {
10
+ if (found.size === 3) {
11
+ break;
12
+ }
13
+ if (isTypeDefinitionNode(definition)) {
14
+ if (definition.name.value === 'Query') {
15
+ foundRootTypes.query = 'Query';
16
+ found.add(OperationTypeNode.QUERY);
17
+ }
18
+ else if (definition.name.value === 'Mutation') {
19
+ foundRootTypes.mutation = 'Mutation';
20
+ found.add(OperationTypeNode.MUTATION);
21
+ }
22
+ else if (definition.name.value === 'Subscription') {
23
+ foundRootTypes.subscription = 'Subscription';
24
+ found.add(OperationTypeNode.SUBSCRIPTION);
25
+ }
26
+ }
27
+ }
28
+ return foundRootTypes;
29
+ }
30
+ function validateSchemaNode(node, definitions, context) {
31
+ const definedDefaultRootTypes = findDefaultRootTypes(definitions);
32
+ for (const operationType of node.operationTypes ?? []) {
33
+ const defaultRootType = definedDefaultRootTypes[operationType.operation];
34
+ const usedRootTypeName = operationType.type.name.value;
35
+ if (defaultRootType && defaultRootType !== usedRootTypeName) {
36
+ context.reportError(new GraphQLError(`The schema has a type named "${defaultRootType}" but it is not set as the ${operationType.operation} root type ("${usedRootTypeName}" is instead): this is not supported by federation. If a root type does not use its default name, there should be no other type with that default name.`, {
37
+ nodes: node,
38
+ extensions: {
39
+ code: `ROOT_${operationType.operation.toUpperCase()}_USED`,
40
+ },
41
+ }));
42
+ }
43
+ }
44
+ }
45
+ export function RootTypeUsedRule(context) {
46
+ const { definitions } = context.getDocument();
47
+ return {
48
+ SchemaDefinition(node) {
49
+ validateSchemaNode(node, definitions, context);
50
+ },
51
+ SchemaExtension(node) {
52
+ validateSchemaNode(node, definitions, context);
53
+ },
54
+ };
55
+ }
@@ -0,0 +1,38 @@
1
+ import { GraphQLError, } from 'graphql';
2
+ export function UniqueArgumentDefinitionNamesRule(context) {
3
+ return {
4
+ DirectiveDefinition(directiveNode) {
5
+ const argumentNodes = directiveNode.arguments ?? [];
6
+ return checkArgUniqueness(`@${directiveNode.name.value}`, argumentNodes);
7
+ },
8
+ InterfaceTypeDefinition: checkArgUniquenessPerField,
9
+ InterfaceTypeExtension: checkArgUniquenessPerField,
10
+ ObjectTypeDefinition: checkArgUniquenessPerField,
11
+ ObjectTypeExtension: checkArgUniquenessPerField,
12
+ };
13
+ function checkArgUniquenessPerField(typeNode) {
14
+ const typeName = typeNode.name.value;
15
+ const fieldNodes = typeNode.fields ?? [];
16
+ for (const fieldDef of fieldNodes) {
17
+ const fieldName = fieldDef.name.value;
18
+ const argumentNodes = fieldDef.arguments ?? [];
19
+ checkArgUniqueness(`${typeName}.${fieldName}`, argumentNodes);
20
+ }
21
+ return false;
22
+ }
23
+ function checkArgUniqueness(parentName, argumentNodes) {
24
+ const visitedArgumentNames = new Set();
25
+ for (const argDef of argumentNodes) {
26
+ if (visitedArgumentNames.has(argDef.name.value)) {
27
+ context.reportError(new GraphQLError(`Argument "${parentName}(${argDef.name.value}:)" can only be defined once.`, {
28
+ extensions: {
29
+ code: 'INVALID_GRAPHQL',
30
+ },
31
+ }));
32
+ }
33
+ else {
34
+ visitedArgumentNames.add(argDef.name.value);
35
+ }
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,23 @@
1
+ import { GraphQLError } from 'graphql';
2
+ export function UniqueArgumentNamesRule(context) {
3
+ return {
4
+ Field: checkArgUniqueness,
5
+ Directive: checkArgUniqueness,
6
+ };
7
+ function checkArgUniqueness(parentNode) {
8
+ const argumentNodes = parentNode.arguments ?? [];
9
+ const seenArgs = new Set();
10
+ for (const argumentNode of argumentNodes) {
11
+ if (seenArgs.has(argumentNode.name.value)) {
12
+ context.reportError(new GraphQLError(`There can be only one argument named "${argumentNode.name.value}".`, {
13
+ extensions: {
14
+ code: 'INVALID_GRAPHQL',
15
+ },
16
+ }));
17
+ }
18
+ else {
19
+ seenArgs.add(argumentNode.name.value);
20
+ }
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,20 @@
1
+ import { GraphQLError } from 'graphql';
2
+ export function UniqueDirectiveNamesRule(context) {
3
+ const knownDirectiveNameNodes = new Set();
4
+ return {
5
+ DirectiveDefinition(node) {
6
+ const directiveName = node.name.value;
7
+ const existingNameNode = knownDirectiveNameNodes.has(directiveName);
8
+ if (existingNameNode) {
9
+ context.reportError(new GraphQLError(`There can be only one directive named "@${directiveName}".`, {
10
+ extensions: {
11
+ code: 'INVALID_GRAPHQL',
12
+ },
13
+ }));
14
+ }
15
+ else {
16
+ knownDirectiveNameNodes.add(directiveName);
17
+ }
18
+ },
19
+ };
20
+ }
@@ -0,0 +1,48 @@
1
+ import { GraphQLError, isTypeDefinitionNode, isTypeExtensionNode, Kind, } from 'graphql';
2
+ export function UniqueDirectivesPerLocationRule(context) {
3
+ const uniqueDirectiveMap = new Map();
4
+ const astDefinitions = context.getDocument().definitions;
5
+ for (const def of astDefinitions) {
6
+ if (def.kind === Kind.DIRECTIVE_DEFINITION) {
7
+ uniqueDirectiveMap.set(def.name.value, !def.repeatable);
8
+ }
9
+ }
10
+ const schemaDirectives = new Set();
11
+ const typeDirectivesMap = new Map();
12
+ return {
13
+ enter(node) {
14
+ if (!('directives' in node) || !node.directives) {
15
+ return;
16
+ }
17
+ let seenDirectives;
18
+ if (node.kind === Kind.SCHEMA_DEFINITION || node.kind === Kind.SCHEMA_EXTENSION) {
19
+ seenDirectives = schemaDirectives;
20
+ }
21
+ else if (isTypeDefinitionNode(node) || isTypeExtensionNode(node)) {
22
+ const typeName = node.name.value;
23
+ if (!typeDirectivesMap.has(typeName)) {
24
+ typeDirectivesMap.set(typeName, new Set());
25
+ }
26
+ seenDirectives = typeDirectivesMap.get(typeName);
27
+ }
28
+ else {
29
+ seenDirectives = new Set();
30
+ }
31
+ for (const directive of node.directives) {
32
+ const directiveName = directive.name.value;
33
+ if (uniqueDirectiveMap.get(directiveName)) {
34
+ if (seenDirectives.has(directiveName)) {
35
+ context.reportError(new GraphQLError(`The directive "@${directiveName}" can only be used once at this location.`, {
36
+ extensions: {
37
+ code: 'INVALID_GRAPHQL',
38
+ },
39
+ }));
40
+ }
41
+ else {
42
+ seenDirectives.add(directive.name.value);
43
+ }
44
+ }
45
+ }
46
+ },
47
+ };
48
+ }
@@ -0,0 +1,29 @@
1
+ import { GraphQLError } from 'graphql';
2
+ export function UniqueEnumValueNamesRule(context) {
3
+ const knownValueNames = new Map();
4
+ return {
5
+ EnumTypeDefinition: checkValueUniqueness,
6
+ EnumTypeExtension: checkValueUniqueness,
7
+ };
8
+ function checkValueUniqueness(node) {
9
+ const typeName = node.name.value;
10
+ if (!knownValueNames.has(typeName)) {
11
+ knownValueNames.set(typeName, new Set());
12
+ }
13
+ const valueNodes = node.values ?? [];
14
+ const valueNames = knownValueNames.get(typeName);
15
+ for (const valueDef of valueNodes) {
16
+ const valueName = valueDef.name.value;
17
+ if (valueNames.has(valueName)) {
18
+ context.reportError(new GraphQLError(`Enum value "${typeName}.${valueName}" can only be defined once.`, {
19
+ extensions: {
20
+ code: 'INVALID_GRAPHQL',
21
+ },
22
+ }));
23
+ }
24
+ else {
25
+ valueNames.add(valueName);
26
+ }
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,33 @@
1
+ import { GraphQLError, } from 'graphql';
2
+ export function UniqueFieldDefinitionNamesRule(context) {
3
+ const knownFieldNames = new Map();
4
+ return {
5
+ InputObjectTypeDefinition: checkFieldUniqueness,
6
+ InputObjectTypeExtension: checkFieldUniqueness,
7
+ InterfaceTypeDefinition: checkFieldUniqueness,
8
+ InterfaceTypeExtension: checkFieldUniqueness,
9
+ ObjectTypeDefinition: checkFieldUniqueness,
10
+ ObjectTypeExtension: checkFieldUniqueness,
11
+ };
12
+ function checkFieldUniqueness(node) {
13
+ const typeName = node.name.value;
14
+ if (!knownFieldNames.has(typeName)) {
15
+ knownFieldNames.set(typeName, new Set());
16
+ }
17
+ const fieldNodes = node.fields ?? [];
18
+ const fieldNames = knownFieldNames.get(typeName);
19
+ for (const fieldDef of fieldNodes) {
20
+ const fieldName = fieldDef.name.value;
21
+ if (fieldNames.has(fieldName)) {
22
+ context.reportError(new GraphQLError(`Field "${typeName}.${fieldName}" can only be defined once.`, {
23
+ extensions: {
24
+ code: 'INVALID_GRAPHQL',
25
+ },
26
+ }));
27
+ }
28
+ else {
29
+ fieldNames.add(fieldName);
30
+ }
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,33 @@
1
+ import { GraphQLError } from 'graphql';
2
+ export function UniqueInputFieldNamesRule(context) {
3
+ const knownNameStack = [];
4
+ let knownNames = new Set();
5
+ return {
6
+ ObjectValue: {
7
+ enter() {
8
+ knownNameStack.push(knownNames);
9
+ knownNames = new Set();
10
+ },
11
+ leave() {
12
+ const prevKnownNames = knownNameStack.pop();
13
+ if (!prevKnownNames) {
14
+ throw new Error('Assertion failed: nothing else in the stack');
15
+ }
16
+ knownNames = prevKnownNames;
17
+ },
18
+ },
19
+ ObjectField(node) {
20
+ const fieldName = node.name.value;
21
+ if (knownNames.has(fieldName)) {
22
+ context.reportError(new GraphQLError(`There can be only one input field named "${fieldName}".`, {
23
+ extensions: {
24
+ code: 'INVALID_GRAPHQL',
25
+ },
26
+ }));
27
+ }
28
+ else {
29
+ knownNames.add(fieldName);
30
+ }
31
+ },
32
+ };
33
+ }
@@ -0,0 +1,25 @@
1
+ import { GraphQLError, } from 'graphql';
2
+ export function UniqueOperationTypesRule(context) {
3
+ const definedOperationTypes = new Set();
4
+ return {
5
+ SchemaDefinition: checkOperationTypes,
6
+ SchemaExtension: checkOperationTypes,
7
+ };
8
+ function checkOperationTypes(node) {
9
+ const operationTypesNodes = node.operationTypes || [];
10
+ for (const operationType of operationTypesNodes) {
11
+ const operation = operationType.operation;
12
+ const alreadyDefinedOperationType = definedOperationTypes.has(operation);
13
+ if (alreadyDefinedOperationType) {
14
+ context.reportError(new GraphQLError(`There can be only one ${operation} type in schema.`, {
15
+ extensions: {
16
+ code: 'INVALID_GRAPHQL',
17
+ },
18
+ }));
19
+ }
20
+ else {
21
+ definedOperationTypes.add(operation);
22
+ }
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,25 @@
1
+ import { GraphQLError } from 'graphql';
2
+ export function UniqueTypeNamesRule(context) {
3
+ const knownTypeNames = new Set();
4
+ return {
5
+ ScalarTypeDefinition: checkTypeName,
6
+ ObjectTypeDefinition: checkTypeName,
7
+ InterfaceTypeDefinition: checkTypeName,
8
+ UnionTypeDefinition: checkTypeName,
9
+ EnumTypeDefinition: checkTypeName,
10
+ InputObjectTypeDefinition: checkTypeName,
11
+ };
12
+ function checkTypeName(node) {
13
+ const typeName = node.name.value;
14
+ if (knownTypeNames.has(typeName)) {
15
+ context.reportError(new GraphQLError(`There can be only one type named "${typeName}".`, {
16
+ extensions: {
17
+ code: 'INVALID_GRAPHQL',
18
+ },
19
+ }));
20
+ }
21
+ else {
22
+ knownTypeNames.add(typeName);
23
+ }
24
+ }
25
+ }