@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,779 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stripFederation = exports.schemaCoordinate = exports.createJoinGraphEnumTypeNode = exports.createScalarTypeNode = exports.createEnumTypeNode = exports.createUnionTypeNode = exports.createInputObjectTypeNode = exports.createInterfaceTypeNode = exports.createObjectTypeNode = exports.createDirectiveNode = exports.createSchemaNode = void 0;
4
+ const graphql_1 = require("graphql");
5
+ function createSchemaNode(schema) {
6
+ return {
7
+ kind: graphql_1.Kind.SCHEMA_DEFINITION,
8
+ directives: schema.links?.map(createLinkDirectiveNode),
9
+ operationTypes: [].concat(schema.query
10
+ ? {
11
+ kind: graphql_1.Kind.OPERATION_TYPE_DEFINITION,
12
+ operation: graphql_1.OperationTypeNode.QUERY,
13
+ type: createNamedTypeNode(schema.query),
14
+ }
15
+ : [], schema.mutation
16
+ ? {
17
+ kind: graphql_1.Kind.OPERATION_TYPE_DEFINITION,
18
+ operation: graphql_1.OperationTypeNode.MUTATION,
19
+ type: createNamedTypeNode(schema.mutation),
20
+ }
21
+ : [], schema.subscription
22
+ ? {
23
+ kind: graphql_1.Kind.OPERATION_TYPE_DEFINITION,
24
+ operation: graphql_1.OperationTypeNode.SUBSCRIPTION,
25
+ type: createNamedTypeNode(schema.subscription),
26
+ }
27
+ : []),
28
+ };
29
+ }
30
+ exports.createSchemaNode = createSchemaNode;
31
+ function createDirectiveNode(directive) {
32
+ return {
33
+ kind: graphql_1.Kind.DIRECTIVE_DEFINITION,
34
+ name: {
35
+ kind: graphql_1.Kind.NAME,
36
+ value: directive.name,
37
+ },
38
+ locations: Array.from(directive.locations).map(location => ({
39
+ kind: graphql_1.Kind.NAME,
40
+ value: location,
41
+ })),
42
+ repeatable: directive.repeatable,
43
+ arguments: directive.arguments.map(createFieldArgumentNode),
44
+ };
45
+ }
46
+ exports.createDirectiveNode = createDirectiveNode;
47
+ function createObjectTypeNode(objectType) {
48
+ return {
49
+ kind: graphql_1.Kind.OBJECT_TYPE_DEFINITION,
50
+ name: {
51
+ kind: graphql_1.Kind.NAME,
52
+ value: objectType.name,
53
+ },
54
+ directives: applyDirectives(objectType),
55
+ fields: objectType.fields.map(createFieldNode),
56
+ description: objectType.description ? createDescriptionNode(objectType.description) : undefined,
57
+ interfaces: objectType.interfaces?.map(createNamedTypeNode),
58
+ };
59
+ }
60
+ exports.createObjectTypeNode = createObjectTypeNode;
61
+ function createInterfaceTypeNode(interfaceType) {
62
+ return {
63
+ kind: graphql_1.Kind.INTERFACE_TYPE_DEFINITION,
64
+ name: {
65
+ kind: graphql_1.Kind.NAME,
66
+ value: interfaceType.name,
67
+ },
68
+ directives: applyDirectives(interfaceType),
69
+ description: interfaceType.description
70
+ ? createDescriptionNode(interfaceType.description)
71
+ : undefined,
72
+ fields: interfaceType.fields.map(createFieldNode),
73
+ interfaces: interfaceType.interfaces?.map(createNamedTypeNode),
74
+ };
75
+ }
76
+ exports.createInterfaceTypeNode = createInterfaceTypeNode;
77
+ function createInputObjectTypeNode(inputObjectType) {
78
+ return {
79
+ kind: graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION,
80
+ name: {
81
+ kind: graphql_1.Kind.NAME,
82
+ value: inputObjectType.name,
83
+ },
84
+ directives: applyDirectives(inputObjectType),
85
+ fields: inputObjectType.fields.map(createInputFieldNode),
86
+ description: inputObjectType.description
87
+ ? createDescriptionNode(inputObjectType.description)
88
+ : undefined,
89
+ };
90
+ }
91
+ exports.createInputObjectTypeNode = createInputObjectTypeNode;
92
+ function createUnionTypeNode(unionType) {
93
+ return {
94
+ kind: graphql_1.Kind.UNION_TYPE_DEFINITION,
95
+ name: {
96
+ kind: graphql_1.Kind.NAME,
97
+ value: unionType.name,
98
+ },
99
+ directives: applyDirectives(unionType),
100
+ description: unionType.description ? createDescriptionNode(unionType.description) : undefined,
101
+ types: unionType.members.map(member => ({
102
+ kind: graphql_1.Kind.NAMED_TYPE,
103
+ name: {
104
+ kind: graphql_1.Kind.NAME,
105
+ value: member,
106
+ },
107
+ })),
108
+ };
109
+ }
110
+ exports.createUnionTypeNode = createUnionTypeNode;
111
+ function createEnumTypeNode(enumType) {
112
+ return {
113
+ kind: graphql_1.Kind.ENUM_TYPE_DEFINITION,
114
+ name: {
115
+ kind: graphql_1.Kind.NAME,
116
+ value: enumType.name,
117
+ },
118
+ directives: applyDirectives(enumType),
119
+ description: enumType.description ? createDescriptionNode(enumType.description) : undefined,
120
+ values: enumType.values.map(createEnumValueNode),
121
+ };
122
+ }
123
+ exports.createEnumTypeNode = createEnumTypeNode;
124
+ function createScalarTypeNode(scalarType) {
125
+ return {
126
+ kind: graphql_1.Kind.SCALAR_TYPE_DEFINITION,
127
+ name: {
128
+ kind: graphql_1.Kind.NAME,
129
+ value: scalarType.name,
130
+ },
131
+ description: scalarType.description ? createDescriptionNode(scalarType.description) : undefined,
132
+ directives: applyDirectives(scalarType),
133
+ };
134
+ }
135
+ exports.createScalarTypeNode = createScalarTypeNode;
136
+ function createJoinGraphEnumTypeNode(graphs) {
137
+ return createEnumTypeNode({
138
+ name: 'join__Graph',
139
+ values: graphs.map(graph => ({
140
+ name: graph.enumValue,
141
+ ast: {
142
+ directives: [createJoinGraphDirectiveNode(graph)],
143
+ },
144
+ })),
145
+ });
146
+ }
147
+ exports.createJoinGraphEnumTypeNode = createJoinGraphEnumTypeNode;
148
+ function createFieldNode(field) {
149
+ return {
150
+ kind: graphql_1.Kind.FIELD_DEFINITION,
151
+ name: {
152
+ kind: graphql_1.Kind.NAME,
153
+ value: field.name,
154
+ },
155
+ type: (0, graphql_1.parseType)(field.type),
156
+ directives: applyDirectives(field),
157
+ description: field.description ? createDescriptionNode(field.description) : undefined,
158
+ arguments: field.arguments?.map(createFieldArgumentNode),
159
+ };
160
+ }
161
+ function createInputFieldNode(inputField) {
162
+ return {
163
+ kind: graphql_1.Kind.INPUT_VALUE_DEFINITION,
164
+ name: {
165
+ kind: graphql_1.Kind.NAME,
166
+ value: inputField.name,
167
+ },
168
+ type: (0, graphql_1.parseType)(inputField.type),
169
+ directives: applyDirectives(inputField),
170
+ description: inputField.description ? createDescriptionNode(inputField.description) : undefined,
171
+ defaultValue: typeof inputField.defaultValue === 'string'
172
+ ? (0, graphql_1.parseConstValue)(inputField.defaultValue)
173
+ : undefined,
174
+ };
175
+ }
176
+ function createEnumValueNode(enumValue) {
177
+ return {
178
+ kind: graphql_1.Kind.ENUM_VALUE_DEFINITION,
179
+ name: {
180
+ kind: graphql_1.Kind.NAME,
181
+ value: enumValue.name,
182
+ },
183
+ directives: applyDirectives(enumValue),
184
+ description: enumValue.description ? createDescriptionNode(enumValue.description) : undefined,
185
+ };
186
+ }
187
+ function createFieldArgumentNode(argument) {
188
+ return {
189
+ kind: graphql_1.Kind.INPUT_VALUE_DEFINITION,
190
+ name: {
191
+ kind: graphql_1.Kind.NAME,
192
+ value: argument.name,
193
+ },
194
+ defaultValue: typeof argument.defaultValue === 'string'
195
+ ? (0, graphql_1.parseConstValue)(argument.defaultValue)
196
+ : undefined,
197
+ type: (0, graphql_1.parseType)(argument.type),
198
+ directives: applyDirectives(argument),
199
+ description: argument.description ? createDescriptionNode(argument.description) : undefined,
200
+ };
201
+ }
202
+ function createJoinTypeDirectiveNode(join) {
203
+ return {
204
+ kind: graphql_1.Kind.DIRECTIVE,
205
+ name: {
206
+ kind: graphql_1.Kind.NAME,
207
+ value: 'join__type',
208
+ },
209
+ arguments: [
210
+ {
211
+ kind: graphql_1.Kind.ARGUMENT,
212
+ name: {
213
+ kind: graphql_1.Kind.NAME,
214
+ value: 'graph',
215
+ },
216
+ value: {
217
+ kind: graphql_1.Kind.ENUM,
218
+ value: join.graph,
219
+ },
220
+ },
221
+ join.key
222
+ ? {
223
+ kind: graphql_1.Kind.ARGUMENT,
224
+ name: {
225
+ kind: graphql_1.Kind.NAME,
226
+ value: 'key',
227
+ },
228
+ value: {
229
+ kind: graphql_1.Kind.STRING,
230
+ value: join.key,
231
+ },
232
+ }
233
+ : null,
234
+ join.resolvable === false
235
+ ? {
236
+ kind: graphql_1.Kind.ARGUMENT,
237
+ name: {
238
+ kind: graphql_1.Kind.NAME,
239
+ value: 'resolvable',
240
+ },
241
+ value: {
242
+ kind: graphql_1.Kind.BOOLEAN,
243
+ value: false,
244
+ },
245
+ }
246
+ : null,
247
+ join.isInterfaceObject
248
+ ? {
249
+ kind: graphql_1.Kind.ARGUMENT,
250
+ name: {
251
+ kind: graphql_1.Kind.NAME,
252
+ value: 'isInterfaceObject',
253
+ },
254
+ value: {
255
+ kind: graphql_1.Kind.BOOLEAN,
256
+ value: true,
257
+ },
258
+ }
259
+ : null,
260
+ join.extension
261
+ ? {
262
+ kind: graphql_1.Kind.ARGUMENT,
263
+ name: {
264
+ kind: graphql_1.Kind.NAME,
265
+ value: 'extension',
266
+ },
267
+ value: {
268
+ kind: graphql_1.Kind.BOOLEAN,
269
+ value: true,
270
+ },
271
+ }
272
+ : null,
273
+ ].filter(nonEmpty),
274
+ };
275
+ }
276
+ function createJoinImplementsDirectiveNode(join) {
277
+ return {
278
+ kind: graphql_1.Kind.DIRECTIVE,
279
+ name: {
280
+ kind: graphql_1.Kind.NAME,
281
+ value: 'join__implements',
282
+ },
283
+ arguments: [
284
+ {
285
+ kind: graphql_1.Kind.ARGUMENT,
286
+ name: {
287
+ kind: graphql_1.Kind.NAME,
288
+ value: 'graph',
289
+ },
290
+ value: {
291
+ kind: graphql_1.Kind.ENUM,
292
+ value: join.graph,
293
+ },
294
+ },
295
+ {
296
+ kind: graphql_1.Kind.ARGUMENT,
297
+ name: {
298
+ kind: graphql_1.Kind.NAME,
299
+ value: 'interface',
300
+ },
301
+ value: {
302
+ kind: graphql_1.Kind.STRING,
303
+ value: join.interface,
304
+ },
305
+ },
306
+ ],
307
+ };
308
+ }
309
+ function createJoinFieldDirectiveNode(join) {
310
+ return {
311
+ kind: graphql_1.Kind.DIRECTIVE,
312
+ name: {
313
+ kind: graphql_1.Kind.NAME,
314
+ value: 'join__field',
315
+ },
316
+ arguments: [
317
+ join.graph
318
+ ? {
319
+ kind: graphql_1.Kind.ARGUMENT,
320
+ name: {
321
+ kind: graphql_1.Kind.NAME,
322
+ value: 'graph',
323
+ },
324
+ value: {
325
+ kind: graphql_1.Kind.ENUM,
326
+ value: join.graph,
327
+ },
328
+ }
329
+ : null,
330
+ join.type
331
+ ? {
332
+ kind: graphql_1.Kind.ARGUMENT,
333
+ name: {
334
+ kind: graphql_1.Kind.NAME,
335
+ value: 'type',
336
+ },
337
+ value: {
338
+ kind: graphql_1.Kind.STRING,
339
+ value: join.type,
340
+ },
341
+ }
342
+ : null,
343
+ join.override
344
+ ? {
345
+ kind: graphql_1.Kind.ARGUMENT,
346
+ name: {
347
+ kind: graphql_1.Kind.NAME,
348
+ value: 'override',
349
+ },
350
+ value: {
351
+ kind: graphql_1.Kind.STRING,
352
+ value: join.override,
353
+ },
354
+ }
355
+ : null,
356
+ join.external
357
+ ? {
358
+ kind: graphql_1.Kind.ARGUMENT,
359
+ name: {
360
+ kind: graphql_1.Kind.NAME,
361
+ value: 'external',
362
+ },
363
+ value: {
364
+ kind: graphql_1.Kind.BOOLEAN,
365
+ value: true,
366
+ },
367
+ }
368
+ : null,
369
+ join.provides
370
+ ? {
371
+ kind: graphql_1.Kind.ARGUMENT,
372
+ name: {
373
+ kind: graphql_1.Kind.NAME,
374
+ value: 'provides',
375
+ },
376
+ value: {
377
+ kind: graphql_1.Kind.STRING,
378
+ value: join.provides,
379
+ },
380
+ }
381
+ : null,
382
+ join.requires
383
+ ? {
384
+ kind: graphql_1.Kind.ARGUMENT,
385
+ name: {
386
+ kind: graphql_1.Kind.NAME,
387
+ value: 'requires',
388
+ },
389
+ value: {
390
+ kind: graphql_1.Kind.STRING,
391
+ value: join.requires,
392
+ },
393
+ }
394
+ : null,
395
+ ].filter(nonEmpty),
396
+ };
397
+ }
398
+ function createJoinUnionMemberDirectiveNode(join) {
399
+ return {
400
+ kind: graphql_1.Kind.DIRECTIVE,
401
+ name: {
402
+ kind: graphql_1.Kind.NAME,
403
+ value: 'join__unionMember',
404
+ },
405
+ arguments: [
406
+ {
407
+ kind: graphql_1.Kind.ARGUMENT,
408
+ name: {
409
+ kind: graphql_1.Kind.NAME,
410
+ value: 'graph',
411
+ },
412
+ value: {
413
+ kind: graphql_1.Kind.ENUM,
414
+ value: join.graph,
415
+ },
416
+ },
417
+ {
418
+ kind: graphql_1.Kind.ARGUMENT,
419
+ name: {
420
+ kind: graphql_1.Kind.NAME,
421
+ value: 'member',
422
+ },
423
+ value: {
424
+ kind: graphql_1.Kind.STRING,
425
+ value: join.member,
426
+ },
427
+ },
428
+ ],
429
+ };
430
+ }
431
+ function createJoinEnumValueDirectiveNode(join) {
432
+ return {
433
+ kind: graphql_1.Kind.DIRECTIVE,
434
+ name: {
435
+ kind: graphql_1.Kind.NAME,
436
+ value: 'join__enumValue',
437
+ },
438
+ arguments: [
439
+ {
440
+ kind: graphql_1.Kind.ARGUMENT,
441
+ name: {
442
+ kind: graphql_1.Kind.NAME,
443
+ value: 'graph',
444
+ },
445
+ value: {
446
+ kind: graphql_1.Kind.ENUM,
447
+ value: join.graph,
448
+ },
449
+ },
450
+ ],
451
+ };
452
+ }
453
+ function createInaccessibleDirectiveNode() {
454
+ return {
455
+ kind: graphql_1.Kind.DIRECTIVE,
456
+ name: {
457
+ kind: graphql_1.Kind.NAME,
458
+ value: 'inaccessible',
459
+ },
460
+ arguments: [],
461
+ };
462
+ }
463
+ function createTagDirectiveNode(name) {
464
+ return {
465
+ kind: graphql_1.Kind.DIRECTIVE,
466
+ name: {
467
+ kind: graphql_1.Kind.NAME,
468
+ value: 'tag',
469
+ },
470
+ arguments: [
471
+ {
472
+ kind: graphql_1.Kind.ARGUMENT,
473
+ name: {
474
+ kind: graphql_1.Kind.NAME,
475
+ value: 'name',
476
+ },
477
+ value: {
478
+ kind: graphql_1.Kind.STRING,
479
+ value: name,
480
+ },
481
+ },
482
+ ],
483
+ };
484
+ }
485
+ function createJoinGraphDirectiveNode(join) {
486
+ return {
487
+ kind: graphql_1.Kind.DIRECTIVE,
488
+ name: {
489
+ kind: graphql_1.Kind.NAME,
490
+ value: 'join__graph',
491
+ },
492
+ arguments: [
493
+ {
494
+ kind: graphql_1.Kind.ARGUMENT,
495
+ name: {
496
+ kind: graphql_1.Kind.NAME,
497
+ value: 'name',
498
+ },
499
+ value: {
500
+ kind: graphql_1.Kind.STRING,
501
+ value: join.name,
502
+ },
503
+ },
504
+ {
505
+ kind: graphql_1.Kind.ARGUMENT,
506
+ name: {
507
+ kind: graphql_1.Kind.NAME,
508
+ value: 'url',
509
+ },
510
+ value: {
511
+ kind: graphql_1.Kind.STRING,
512
+ value: join.url ?? '',
513
+ },
514
+ },
515
+ ],
516
+ };
517
+ }
518
+ function createDescriptionNode(description) {
519
+ return {
520
+ kind: graphql_1.Kind.STRING,
521
+ value: description.value,
522
+ block: true,
523
+ };
524
+ }
525
+ function createDeprecatedDirectiveNode(deprecated) {
526
+ return {
527
+ kind: graphql_1.Kind.DIRECTIVE,
528
+ name: {
529
+ kind: graphql_1.Kind.NAME,
530
+ value: 'deprecated',
531
+ },
532
+ arguments: typeof deprecated.reason === 'string'
533
+ ? [
534
+ {
535
+ kind: graphql_1.Kind.ARGUMENT,
536
+ name: {
537
+ kind: graphql_1.Kind.NAME,
538
+ value: 'reason',
539
+ },
540
+ value: {
541
+ kind: graphql_1.Kind.STRING,
542
+ value: deprecated.reason,
543
+ },
544
+ },
545
+ ]
546
+ : [],
547
+ };
548
+ }
549
+ function createSpecifiedByDirectiveNode(url) {
550
+ return {
551
+ kind: graphql_1.Kind.DIRECTIVE,
552
+ name: {
553
+ kind: graphql_1.Kind.NAME,
554
+ value: 'specifiedBy',
555
+ },
556
+ arguments: [
557
+ {
558
+ kind: graphql_1.Kind.ARGUMENT,
559
+ name: {
560
+ kind: graphql_1.Kind.NAME,
561
+ value: 'url',
562
+ },
563
+ value: {
564
+ kind: graphql_1.Kind.STRING,
565
+ value: url,
566
+ },
567
+ },
568
+ ],
569
+ };
570
+ }
571
+ function createLinkDirectiveNode(link) {
572
+ return {
573
+ kind: graphql_1.Kind.DIRECTIVE,
574
+ name: {
575
+ kind: graphql_1.Kind.NAME,
576
+ value: 'link',
577
+ },
578
+ arguments: [].concat([
579
+ {
580
+ kind: graphql_1.Kind.ARGUMENT,
581
+ name: {
582
+ kind: graphql_1.Kind.NAME,
583
+ value: 'url',
584
+ },
585
+ value: {
586
+ kind: graphql_1.Kind.STRING,
587
+ value: link.url,
588
+ },
589
+ },
590
+ ], link.for
591
+ ? [
592
+ {
593
+ kind: graphql_1.Kind.ARGUMENT,
594
+ name: {
595
+ kind: graphql_1.Kind.NAME,
596
+ value: 'for',
597
+ },
598
+ value: {
599
+ kind: graphql_1.Kind.ENUM,
600
+ value: link.for,
601
+ },
602
+ },
603
+ ]
604
+ : [], link.import
605
+ ? [
606
+ {
607
+ kind: graphql_1.Kind.ARGUMENT,
608
+ name: {
609
+ kind: graphql_1.Kind.NAME,
610
+ value: 'import',
611
+ },
612
+ value: {
613
+ kind: graphql_1.Kind.LIST,
614
+ values: link.import.map(imported => {
615
+ if (imported.alias) {
616
+ return {
617
+ kind: graphql_1.Kind.OBJECT,
618
+ fields: [
619
+ {
620
+ kind: graphql_1.Kind.OBJECT_FIELD,
621
+ name: {
622
+ kind: graphql_1.Kind.NAME,
623
+ value: 'name',
624
+ },
625
+ value: {
626
+ kind: graphql_1.Kind.STRING,
627
+ value: imported.name,
628
+ },
629
+ },
630
+ ],
631
+ };
632
+ }
633
+ return {
634
+ kind: graphql_1.Kind.STRING,
635
+ value: imported.name,
636
+ };
637
+ }),
638
+ },
639
+ },
640
+ ]
641
+ : []),
642
+ };
643
+ }
644
+ function createNamedTypeNode(name) {
645
+ return {
646
+ kind: graphql_1.Kind.NAMED_TYPE,
647
+ name: {
648
+ kind: graphql_1.Kind.NAME,
649
+ value: name,
650
+ },
651
+ };
652
+ }
653
+ function applyDirectives(common) {
654
+ return [].concat(common.ast?.directives ?? [], common.join?.type?.map(createJoinTypeDirectiveNode) ?? [], common.join?.implements?.map(createJoinImplementsDirectiveNode) ?? [], common.join?.field?.map(createJoinFieldDirectiveNode) ?? [], common.join?.unionMember?.map(createJoinUnionMemberDirectiveNode) ?? [], common.join?.enumValue?.map(createJoinEnumValueDirectiveNode) ?? [], common.tags?.map(createTagDirectiveNode) ?? [], common.inaccessible ? [createInaccessibleDirectiveNode()] : [], common.deprecated ? [createDeprecatedDirectiveNode(common.deprecated)] : [], common.specifiedBy ? [createSpecifiedByDirectiveNode(common.specifiedBy)] : []);
655
+ }
656
+ function nonEmpty(value) {
657
+ return value != null;
658
+ }
659
+ const buildInDirectives = new Set(graphql_1.specifiedDirectives.map(directive => directive.name));
660
+ function isBuiltInDirective(directiveName) {
661
+ return buildInDirectives.has(directiveName);
662
+ }
663
+ function isFederationDirective(name) {
664
+ return (name === 'tag' || name === 'link' || name.startsWith('join__') || name.startsWith('link__'));
665
+ }
666
+ function isFederationEnum(name) {
667
+ return name.startsWith('join__') || name.startsWith('link__');
668
+ }
669
+ function isFederationScalar(name) {
670
+ return name.startsWith('join__') || name.startsWith('link__');
671
+ }
672
+ function schemaCoordinate(paths, nodes) {
673
+ let coordinate = '';
674
+ for (let i = 0; i < Math.max(paths.length, nodes.length); i++) {
675
+ const prop = paths[i];
676
+ const current = nodes[i];
677
+ if (typeof prop === 'number' && Array.isArray(current)) {
678
+ const node = current[prop];
679
+ if (coordinate.length > 0) {
680
+ coordinate = coordinate + '.' + node.name.value;
681
+ }
682
+ else {
683
+ coordinate = node.name.value;
684
+ }
685
+ }
686
+ }
687
+ return coordinate;
688
+ }
689
+ exports.schemaCoordinate = schemaCoordinate;
690
+ function stripFederation(supergraph) {
691
+ const inaccessible = new Set();
692
+ const documentWithoutFederation = (0, graphql_1.visit)(supergraph, (0, graphql_1.visitInParallel)([
693
+ {
694
+ DirectiveDefinition(node) {
695
+ if (isBuiltInDirective(node.name.value) || isFederationDirective(node.name.value)) {
696
+ return null;
697
+ }
698
+ },
699
+ Directive(node) {
700
+ if (isBuiltInDirective(node.name.value) || isFederationDirective(node.name.value)) {
701
+ return null;
702
+ }
703
+ },
704
+ EnumTypeDefinition(node) {
705
+ if (isFederationEnum(node.name.value)) {
706
+ return null;
707
+ }
708
+ },
709
+ ScalarTypeDefinition(node) {
710
+ if (isFederationScalar(node.name.value)) {
711
+ return null;
712
+ }
713
+ },
714
+ },
715
+ {
716
+ Directive(directive, _, __, paths, nodes) {
717
+ if (directive.name.value === 'inaccessible') {
718
+ inaccessible.add(schemaCoordinate(paths, nodes));
719
+ }
720
+ },
721
+ },
722
+ ]));
723
+ if (inaccessible.size === 0) {
724
+ return documentWithoutFederation;
725
+ }
726
+ function hideByNodeName(node) {
727
+ if (inaccessible.has(node.name.value)) {
728
+ return null;
729
+ }
730
+ }
731
+ function hideObjectOrInterface(node) {
732
+ if (inaccessible.has(node.name.value)) {
733
+ return null;
734
+ }
735
+ const inaccessibleInterfaces = node.interfaces?.filter(i => inaccessible.has(i.name.value));
736
+ if (inaccessibleInterfaces?.length) {
737
+ return {
738
+ ...node,
739
+ interfaces: node.interfaces?.filter(i => !inaccessible.has(i.name.value)),
740
+ };
741
+ }
742
+ }
743
+ function hideField(node, _, __, paths, nodes) {
744
+ if (inaccessible.has(schemaCoordinate(paths, nodes) + '.' + node.name.value)) {
745
+ return null;
746
+ }
747
+ if (inaccessible.has(namedTypeFromTypeNode(node.type).name.value)) {
748
+ return null;
749
+ }
750
+ }
751
+ return (0, graphql_1.visit)(documentWithoutFederation, {
752
+ ObjectTypeDefinition: hideObjectOrInterface,
753
+ InterfaceTypeDefinition: hideObjectOrInterface,
754
+ InputObjectTypeDefinition: hideByNodeName,
755
+ EnumTypeDefinition: hideByNodeName,
756
+ UnionTypeDefinition: hideByNodeName,
757
+ ScalarTypeDefinition: hideByNodeName,
758
+ FieldDefinition: hideField,
759
+ InputValueDefinition: hideField,
760
+ EnumValueDefinition(node, _, __, paths, nodes) {
761
+ if (inaccessible.has(schemaCoordinate(paths, nodes) + '.' + node.name.value)) {
762
+ return null;
763
+ }
764
+ },
765
+ });
766
+ }
767
+ exports.stripFederation = stripFederation;
768
+ function namedTypeFromTypeNode(type) {
769
+ if (type.kind === graphql_1.Kind.NAMED_TYPE) {
770
+ return type;
771
+ }
772
+ if (type.kind === graphql_1.Kind.LIST_TYPE) {
773
+ return namedTypeFromTypeNode(type.type);
774
+ }
775
+ if (type.kind === graphql_1.Kind.NON_NULL_TYPE) {
776
+ return namedTypeFromTypeNode(type.type);
777
+ }
778
+ throw new Error('Unknown type node: ' + type);
779
+ }