@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,211 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detectFederationVersion = exports.isFederationLink = exports.createSpecSchema = exports.isFederationVersion = void 0;
4
+ const graphql_1 = require("graphql");
5
+ const printer_js_1 = require("../graphql/printer.js");
6
+ const inaccessible_js_1 = require("./inaccessible.js");
7
+ const link_js_1 = require("./link.js");
8
+ const tag_js_1 = require("./tag.js");
9
+ function isFederationVersion(version) {
10
+ return version in federationSpecFactory;
11
+ }
12
+ exports.isFederationVersion = isFederationVersion;
13
+ function createSpecSchema(version, imports) {
14
+ if (!isFederationVersion(version)) {
15
+ throw new graphql_1.GraphQLError(`Invalid version ${version} for the federation feature in @link direction on schema`, {
16
+ extensions: {
17
+ code: 'UNKNOWN_FEDERATION_LINK_VERSION',
18
+ },
19
+ });
20
+ }
21
+ if (version !== 'v1.0') {
22
+ const spec = federationSpecFactory[version]('', imports);
23
+ const namespacedSpec = federationSpecFactory[version]('federation__');
24
+ return {
25
+ directives: spec.directives.concat(namespacedSpec.directives),
26
+ types: spec.types.concat(namespacedSpec.types),
27
+ };
28
+ }
29
+ const spec = federationSpecFactory[version]('');
30
+ return {
31
+ directives: spec.directives.concat([tag_js_1.directive, inaccessible_js_1.directive]),
32
+ types: spec.types,
33
+ };
34
+ }
35
+ exports.createSpecSchema = createSpecSchema;
36
+ const federationSpecFactory = {
37
+ 'v1.0': (prefix) => createTypeDefinitions(`
38
+ directive @key(
39
+ fields: _FieldSet!
40
+ resolvable: Boolean = true
41
+ ) repeatable on OBJECT | INTERFACE
42
+ directive @requires(fields: _FieldSet!) on FIELD_DEFINITION
43
+ directive @provides(fields: _FieldSet!) on FIELD_DEFINITION
44
+ directive @external on OBJECT | FIELD_DEFINITION
45
+ directive @extends on OBJECT | INTERFACE
46
+ # @override is not supported in v1 but somehow it's supported by Apollo Composition
47
+ directive @override(from: String!) on FIELD_DEFINITION
48
+ scalar _FieldSet
49
+ `, prefix),
50
+ 'v2.0': (prefix, imports) => createTypeDefinitions(`
51
+ directive @key(
52
+ fields: FieldSet!
53
+ resolvable: Boolean = true
54
+ ) repeatable on OBJECT | INTERFACE
55
+ directive @requires(fields: FieldSet!) on FIELD_DEFINITION
56
+ directive @provides(fields: FieldSet!) on FIELD_DEFINITION
57
+ directive @external on OBJECT | FIELD_DEFINITION
58
+ directive @shareable on FIELD_DEFINITION | OBJECT
59
+ directive @extends on OBJECT | INTERFACE
60
+ directive @override(from: String!) on FIELD_DEFINITION
61
+ directive @inaccessible on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ENUM | ENUM_VALUE | SCALAR | INPUT_OBJECT | INPUT_FIELD_DEFINITION | ARGUMENT_DEFINITION
62
+ directive @tag(
63
+ name: String!
64
+ ) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
65
+ scalar FieldSet
66
+ `, prefix, imports),
67
+ 'v2.1': (prefix, imports) => createTypeDefinitions(`
68
+ directive @composeDirective(name: String!) repeatable on SCHEMA
69
+ directive @extends on OBJECT | INTERFACE
70
+ directive @external on OBJECT | FIELD_DEFINITION
71
+ directive @key(
72
+ fields: FieldSet!
73
+ resolvable: Boolean = true
74
+ ) repeatable on OBJECT | INTERFACE
75
+ directive @inaccessible on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ENUM | ENUM_VALUE | SCALAR | INPUT_OBJECT | INPUT_FIELD_DEFINITION | ARGUMENT_DEFINITION
76
+ directive @override(from: String!) on FIELD_DEFINITION
77
+ directive @provides(fields: FieldSet!) on FIELD_DEFINITION
78
+ directive @requires(fields: FieldSet!) on FIELD_DEFINITION
79
+ directive @shareable on FIELD_DEFINITION | OBJECT
80
+ directive @tag(
81
+ name: String!
82
+ ) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
83
+ scalar FieldSet
84
+ `, prefix, imports),
85
+ 'v2.2': (prefix, imports) => createTypeDefinitions(`
86
+ directive @composeDirective(name: String!) repeatable on SCHEMA
87
+ directive @extends on OBJECT | INTERFACE
88
+ directive @external on OBJECT | FIELD_DEFINITION
89
+ directive @key(
90
+ fields: FieldSet!
91
+ resolvable: Boolean = true
92
+ ) repeatable on OBJECT | INTERFACE
93
+ directive @inaccessible on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ENUM | ENUM_VALUE | SCALAR | INPUT_OBJECT | INPUT_FIELD_DEFINITION | ARGUMENT_DEFINITION
94
+ directive @override(from: String!) on FIELD_DEFINITION
95
+ directive @provides(fields: FieldSet!) on FIELD_DEFINITION
96
+ directive @requires(fields: FieldSet!) on FIELD_DEFINITION
97
+ directive @shareable repeatable on FIELD_DEFINITION | OBJECT
98
+ directive @tag(
99
+ name: String!
100
+ ) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
101
+ scalar FieldSet
102
+ `, prefix, imports),
103
+ 'v2.3': (prefix, imports) => createTypeDefinitions(`
104
+ directive @composeDirective(name: String!) repeatable on SCHEMA
105
+ directive @extends on OBJECT | INTERFACE
106
+ directive @external on OBJECT | FIELD_DEFINITION
107
+ directive @key(
108
+ fields: FieldSet!
109
+ resolvable: Boolean = true
110
+ ) repeatable on OBJECT | INTERFACE
111
+ directive @inaccessible on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ENUM | ENUM_VALUE | SCALAR | INPUT_OBJECT | INPUT_FIELD_DEFINITION | ARGUMENT_DEFINITION
112
+ directive @interfaceObject on OBJECT
113
+ directive @override(from: String!) on FIELD_DEFINITION
114
+ directive @provides(fields: FieldSet!) on FIELD_DEFINITION
115
+ directive @requires(fields: FieldSet!) on FIELD_DEFINITION
116
+ directive @shareable repeatable on FIELD_DEFINITION | OBJECT
117
+ directive @tag(
118
+ name: String!
119
+ ) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
120
+ scalar FieldSet
121
+ `, prefix, imports),
122
+ };
123
+ function createTypeDefinitions(doc, prefix, imports) {
124
+ const shouldFilter = !!imports;
125
+ const toInclude = new Set(imports?.map(i => i.name.replace(/^@/, '')));
126
+ const docAST = (0, graphql_1.parse)(doc, {
127
+ noLocation: true,
128
+ });
129
+ if (!imports?.length ||
130
+ toInclude.has('key') ||
131
+ toInclude.has('requires') ||
132
+ toInclude.has('provides')) {
133
+ toInclude.add('FieldSet');
134
+ toInclude.add('federation__FieldSet');
135
+ }
136
+ const directives = [];
137
+ const types = [];
138
+ for (const node of docAST.definitions) {
139
+ if (isDirectiveDefinitionNode(node)) {
140
+ directives.push(applyPrefix(node, prefix));
141
+ }
142
+ else {
143
+ types.push(applyPrefix(node, prefix));
144
+ }
145
+ }
146
+ return {
147
+ directives: directives.filter(d => !graphql_1.specifiedDirectives.some(sd => sd.name === d.name.value) &&
148
+ (!shouldFilter || toInclude.has(d.name.value))),
149
+ types: types.filter(t => toInclude.has(t.name.value)),
150
+ };
151
+ }
152
+ function isDirectiveDefinitionNode(node) {
153
+ return node.kind === graphql_1.Kind.DIRECTIVE_DEFINITION;
154
+ }
155
+ function applyPrefix(node, prefix) {
156
+ if (prefix.length === 0) {
157
+ return node;
158
+ }
159
+ node.name.value = `${prefix}${node.name.value}`;
160
+ if (isDirectiveDefinitionNode(node)) {
161
+ node.arguments?.forEach(arg => {
162
+ const nameNode = resolveNamedType(arg.type);
163
+ if (!graphql_1.specifiedScalarTypes.some(t => t.name === nameNode.value)) {
164
+ nameNode.value = `${prefix}${nameNode.value}`;
165
+ }
166
+ });
167
+ }
168
+ return node;
169
+ }
170
+ function resolveNamedType(node) {
171
+ if (node.kind === graphql_1.Kind.LIST_TYPE) {
172
+ return resolveNamedType(node.type);
173
+ }
174
+ if (node.kind === graphql_1.Kind.NON_NULL_TYPE) {
175
+ return resolveNamedType(node.type);
176
+ }
177
+ return node.name;
178
+ }
179
+ function isFederationLink(link) {
180
+ return link.identity === 'https://specs.apollo.dev/federation';
181
+ }
182
+ exports.isFederationLink = isFederationLink;
183
+ function detectFederationVersion(typeDefs) {
184
+ for (const definition of typeDefs.definitions) {
185
+ if (definition.kind === graphql_1.Kind.SCHEMA_EXTENSION || definition.kind === graphql_1.Kind.SCHEMA_DEFINITION) {
186
+ const links = definition.directives?.filter(directive => directive.name.value === 'link');
187
+ if (links?.length) {
188
+ const parsedLinks = links.map(l => {
189
+ const url = l.arguments?.find(a => a.name.value === 'url');
190
+ const importArg = l.arguments?.find(a => a.name.value === 'import');
191
+ if (!url) {
192
+ throw new Error('Invalid @link directive');
193
+ }
194
+ return (0, link_js_1.parseLink)(url.value.value, importArg ? (0, printer_js_1.print)(importArg.value) : '[]');
195
+ });
196
+ const fedLink = parsedLinks.find(l => l.identity === 'https://specs.apollo.dev/federation');
197
+ if (fedLink?.version) {
198
+ if (!isFederationVersion(fedLink.version)) {
199
+ throw new Error(`Unsupported federation version: ${fedLink.version}`);
200
+ }
201
+ return {
202
+ version: fedLink.version,
203
+ imports: fedLink.imports,
204
+ };
205
+ }
206
+ }
207
+ }
208
+ }
209
+ return { version: 'v1.0', imports: [] };
210
+ }
211
+ exports.detectFederationVersion = detectFederationVersion;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.directive = exports.typeDefs = exports.sdl = void 0;
4
+ const graphql_1 = require("graphql");
5
+ const helpers_js_1 = require("../graphql/helpers.js");
6
+ exports.sdl = `
7
+ directive @inaccessible on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ENUM | ENUM_VALUE | SCALAR | INPUT_OBJECT | INPUT_FIELD_DEFINITION | ARGUMENT_DEFINITION
8
+ `;
9
+ exports.typeDefs = (0, graphql_1.parse)(exports.sdl);
10
+ exports.directive = exports.typeDefs.definitions.filter(helpers_js_1.isDirectiveDefinition)[0];
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sdl = void 0;
4
+ exports.sdl = `
5
+ directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE
6
+
7
+ directive @join__field(
8
+ graph: join__Graph
9
+ requires: join__FieldSet
10
+ provides: join__FieldSet
11
+ type: String
12
+ external: Boolean
13
+ override: String
14
+ usedOverridden: Boolean
15
+ ) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
16
+
17
+ directive @join__graph(name: String!, url: String!) on ENUM_VALUE
18
+
19
+ directive @join__implements(
20
+ graph: join__Graph!
21
+ interface: String!
22
+ ) repeatable on OBJECT | INTERFACE
23
+
24
+ directive @join__type(
25
+ graph: join__Graph!
26
+ key: join__FieldSet
27
+ extension: Boolean! = false
28
+ resolvable: Boolean! = true
29
+ isInterfaceObject: Boolean! = false
30
+ ) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR
31
+
32
+ directive @join__unionMember(graph: join__Graph!, member: String!) repeatable on UNION
33
+
34
+ scalar join__FieldSet
35
+ `;
@@ -0,0 +1,222 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.sdl = exports.parseLinkDirective = exports.parseLink = exports.mergeLinks = exports.parseLinkImport = exports.parseLinkUrl = exports.printLink = void 0;
7
+ const graphql_1 = require("graphql");
8
+ const json5_1 = __importDefault(require("json5"));
9
+ const printer_js_1 = require("../graphql/printer.js");
10
+ function printLink(link) {
11
+ return (0, printer_js_1.print)({
12
+ kind: graphql_1.Kind.DIRECTIVE,
13
+ name: {
14
+ kind: graphql_1.Kind.NAME,
15
+ value: 'link',
16
+ },
17
+ arguments: [
18
+ {
19
+ kind: graphql_1.Kind.ARGUMENT,
20
+ name: {
21
+ kind: graphql_1.Kind.NAME,
22
+ value: 'url',
23
+ },
24
+ value: {
25
+ kind: graphql_1.Kind.STRING,
26
+ value: [link.identity, link.version].filter(Boolean).join('/'),
27
+ },
28
+ },
29
+ {
30
+ kind: graphql_1.Kind.ARGUMENT,
31
+ name: {
32
+ kind: graphql_1.Kind.NAME,
33
+ value: 'import',
34
+ },
35
+ value: {
36
+ kind: graphql_1.Kind.LIST,
37
+ values: link.imports.map(im => ({
38
+ kind: graphql_1.Kind.STRING,
39
+ value: im.name,
40
+ })),
41
+ },
42
+ },
43
+ ],
44
+ });
45
+ }
46
+ exports.printLink = printLink;
47
+ function parseLinkUrl(urlString) {
48
+ const url = new URL(urlString);
49
+ const parts = url.pathname.split('/').filter(Boolean);
50
+ const len = parts.length;
51
+ if (!len) {
52
+ return { name: null, version: null, identity: url.origin };
53
+ }
54
+ const last = parts[len - 1];
55
+ const secondLast = parts[len - 2];
56
+ const potentiallyNameAndVersion = typeof secondLast === 'string';
57
+ if (potentiallyNameAndVersion) {
58
+ return {
59
+ name: secondLast,
60
+ version: last,
61
+ identity: url.origin +
62
+ '/' +
63
+ parts
64
+ .slice(0, len - 2)
65
+ .concat(secondLast)
66
+ .join('/'),
67
+ };
68
+ }
69
+ if (/^v\d+/i.test(last)) {
70
+ return {
71
+ name: null,
72
+ version: last,
73
+ identity: url.origin,
74
+ };
75
+ }
76
+ return {
77
+ name: last,
78
+ version: null,
79
+ identity: url.origin +
80
+ '/' +
81
+ parts
82
+ .slice(0, len - 2)
83
+ .concat(last)
84
+ .join('/'),
85
+ };
86
+ }
87
+ exports.parseLinkUrl = parseLinkUrl;
88
+ function parseLinkImport(importString) {
89
+ try {
90
+ const bindings = json5_1.default.parse(importString);
91
+ if (!Array.isArray(bindings)) {
92
+ throw new Error(`Expected an array`);
93
+ }
94
+ return bindings.map(binding => {
95
+ if (typeof binding === 'string') {
96
+ return {
97
+ kind: binding.startsWith('@') ? 'directive' : 'type',
98
+ name: binding,
99
+ };
100
+ }
101
+ if (typeof binding === 'object' && binding.name) {
102
+ const nameKind = binding.name.startsWith('@') ? 'directive' : 'type';
103
+ if (!binding.as) {
104
+ return {
105
+ kind: nameKind,
106
+ name: binding.name,
107
+ };
108
+ }
109
+ const aliasKind = binding.as.startsWith('@') ? 'directive' : 'type';
110
+ if (nameKind !== aliasKind) {
111
+ throw new Error(`${binding.name} and ${binding.as} must be of the same kind`);
112
+ }
113
+ return {
114
+ kind: nameKind,
115
+ name: binding.name,
116
+ alias: binding.as,
117
+ };
118
+ }
119
+ throw new Error(`Syntax`);
120
+ });
121
+ }
122
+ catch (error) {
123
+ throw new Error(`Invalid import binding: ${importString}: ${String(error)}`);
124
+ }
125
+ }
126
+ exports.parseLinkImport = parseLinkImport;
127
+ function mergeLinks(links) {
128
+ const groupByIdentity = new Map();
129
+ for (const link of links) {
130
+ const existing = groupByIdentity.get(link.identity);
131
+ if (!existing) {
132
+ const importedDirectives = link.imports.filter(im => im.kind === 'directive');
133
+ if (importedDirectives.length === 0) {
134
+ continue;
135
+ }
136
+ groupByIdentity.set(link.identity, {
137
+ name: link.name,
138
+ highestVersion: link.version ?? '',
139
+ imports: link.imports.filter(im => im.kind === 'directive'),
140
+ });
141
+ }
142
+ else {
143
+ if (link.version &&
144
+ parseFloat(link.version.replace('v', '')) >
145
+ parseFloat(existing.highestVersion.replace('v', ''))) {
146
+ existing.highestVersion = link.version;
147
+ }
148
+ for (const im of link.imports) {
149
+ if (im.kind === 'type') {
150
+ continue;
151
+ }
152
+ const hasImport = existing.imports.some(existingIm => existingIm.kind === im.kind && existingIm.name === im.name);
153
+ if (!hasImport) {
154
+ existing.imports.push(im);
155
+ }
156
+ }
157
+ if (link.name) {
158
+ existing.name = link.name;
159
+ }
160
+ }
161
+ }
162
+ return Array.from(groupByIdentity.entries()).map(([identity, link]) => ({
163
+ identity,
164
+ version: link.highestVersion,
165
+ imports: Array.from(link.imports).map(link => ({ kind: link.kind, name: link.name })),
166
+ name: link.name,
167
+ }));
168
+ }
169
+ exports.mergeLinks = mergeLinks;
170
+ function parseLink(urlString, importString) {
171
+ const spec = parseLinkUrl(urlString);
172
+ return {
173
+ name: spec.name,
174
+ version: spec.version,
175
+ identity: spec.identity,
176
+ imports: parseLinkImport(importString),
177
+ };
178
+ }
179
+ exports.parseLink = parseLink;
180
+ function parseLinkDirective(directive) {
181
+ const urlArg = directive.arguments?.find(isUrlArgument);
182
+ if (!urlArg) {
183
+ return null;
184
+ }
185
+ const importArg = directive.arguments?.find(isImportArgument);
186
+ const spec = parseLinkUrl(urlArg?.value.value);
187
+ return {
188
+ name: spec.name,
189
+ version: spec.version,
190
+ identity: spec.identity,
191
+ imports: parseLinkImport(importArg ? (0, printer_js_1.print)(importArg.value) : '[]'),
192
+ };
193
+ }
194
+ exports.parseLinkDirective = parseLinkDirective;
195
+ function isUrlArgument(arg) {
196
+ return arg.name.value === 'url' && arg.value.kind === graphql_1.Kind.STRING;
197
+ }
198
+ function isImportArgument(arg) {
199
+ return arg.name.value === 'import' && arg.value.kind === graphql_1.Kind.LIST;
200
+ }
201
+ exports.sdl = `
202
+ directive @link(
203
+ url: String
204
+ as: String
205
+ for: link__Purpose
206
+ import: [link__Import]
207
+ ) repeatable on SCHEMA
208
+
209
+ scalar link__Import
210
+
211
+ enum link__Purpose {
212
+ """
213
+ \`SECURITY\` features provide metadata necessary to securely resolve fields.
214
+ """
215
+ SECURITY
216
+
217
+ """
218
+ \`EXECUTION\` features provide metadata necessary for operation execution.
219
+ """
220
+ EXECUTION
221
+ }
222
+ `;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.directive = exports.typeDefs = exports.sdl = void 0;
4
+ const graphql_1 = require("graphql");
5
+ const helpers_js_1 = require("../graphql/helpers.js");
6
+ exports.sdl = `
7
+ directive @tag(
8
+ name: String!
9
+ ) repeatable on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | SCHEMA
10
+ `;
11
+ exports.typeDefs = (0, graphql_1.parse)(exports.sdl);
12
+ exports.directive = exports.typeDefs.definitions.filter(helpers_js_1.isDirectiveDefinition)[0];