@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,476 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUnionType = exports.isInterfaceType = exports.isObjectType = exports.isEnumType = exports.isScalarType = exports.isInputObjectType = exports.typeExists = exports.isInputType = exports.isTypeSubTypeOf = exports.validateSubgraphState = void 0;
4
+ const graphql_1 = require("graphql");
5
+ const format_js_1 = require("../../utils/format.js");
6
+ const state_js_1 = require("../../utils/state.js");
7
+ const state_js_2 = require("../state.js");
8
+ const specifiedScalars = new Set(graphql_1.specifiedScalarTypes.map(t => t.name));
9
+ function validateSubgraphState(state) {
10
+ const errors = [];
11
+ function reportError(message) {
12
+ errors.push(new graphql_1.GraphQLError(message, {
13
+ extensions: {
14
+ code: 'INVALID_GRAPHQL',
15
+ },
16
+ }));
17
+ }
18
+ validateRootTypes(state, reportError);
19
+ validateTypes(state, reportError);
20
+ return errors;
21
+ }
22
+ exports.validateSubgraphState = validateSubgraphState;
23
+ function validateRootTypes(state, reportError) {
24
+ const rootTypesMap = new Map();
25
+ for (const key in state.schema) {
26
+ const rootTypeKind = key;
27
+ const rootTypeName = state.schema[rootTypeKind];
28
+ if (rootTypeName) {
29
+ const rootType = state.types.get(rootTypeName);
30
+ if (!rootType) {
31
+ continue;
32
+ }
33
+ if (!isObjectType(rootType)) {
34
+ const operationTypeStr = capitalize(rootTypeKind.replace('Type', ''));
35
+ reportError(rootTypeKind === 'queryType'
36
+ ? `${operationTypeStr} root type must be Object type, it cannot be ${rootTypeName}.`
37
+ : `${operationTypeStr} root type must be Object type if provided, it cannot be ${rootTypeName}.`);
38
+ }
39
+ else {
40
+ const existing = rootTypesMap.get(rootTypeName);
41
+ if (existing) {
42
+ existing.add(rootTypeKind);
43
+ }
44
+ else {
45
+ rootTypesMap.set(rootTypeName, new Set([rootTypeKind]));
46
+ }
47
+ }
48
+ }
49
+ }
50
+ for (const [rootTypeName, operationTypes] of rootTypesMap) {
51
+ if (operationTypes.size > 1) {
52
+ const operationList = (0, format_js_1.andList)(Array.from(operationTypes).map(op => capitalize(op.replace('Type', ''))));
53
+ reportError(`All root types must be different, "${rootTypeName}" type is used as ${operationList} root types.`);
54
+ }
55
+ }
56
+ }
57
+ function capitalize(str) {
58
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
59
+ }
60
+ function validateTypes(state, reportError) {
61
+ const validateInputObjectCircularRefs = createInputObjectCircularRefsValidator(state, reportError);
62
+ const implementationsMap = new Map();
63
+ for (const type of state.types.values()) {
64
+ if (isInterfaceType(type)) {
65
+ for (const iface of type.interfaces) {
66
+ const interfaceType = state.types.get(iface);
67
+ if (interfaceType && isInterfaceType(interfaceType)) {
68
+ let implementations = implementationsMap.get(iface);
69
+ if (implementations === undefined) {
70
+ implementationsMap.set(iface, new Set([type.name]));
71
+ }
72
+ else {
73
+ implementations.add(type.name);
74
+ }
75
+ }
76
+ }
77
+ }
78
+ else if (isObjectType(type)) {
79
+ for (const iface of type.interfaces) {
80
+ const interfaceType = state.types.get(iface);
81
+ if (interfaceType && isInterfaceType(interfaceType)) {
82
+ let implementations = implementationsMap.get(iface);
83
+ if (implementations === undefined) {
84
+ implementationsMap.set(iface, new Set([type.name]));
85
+ }
86
+ else {
87
+ implementations.add(type.name);
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ for (const type of state.types.values()) {
94
+ if (!isIntrospectionType(type.name)) {
95
+ validateName(reportError, type.name);
96
+ }
97
+ if (isObjectType(type)) {
98
+ validateFields(state, reportError, type);
99
+ validateInterfaces(state, implementationsMap, reportError, type);
100
+ }
101
+ else if (isInterfaceType(type)) {
102
+ validateFields(state, reportError, type);
103
+ validateInterfaces(state, implementationsMap, reportError, type);
104
+ }
105
+ else if (isUnionType(type)) {
106
+ validateUnionMembers(state, reportError, type);
107
+ }
108
+ else if (isEnumType(type)) {
109
+ validateEnumValues(reportError, type);
110
+ }
111
+ else if (isInputObjectType(type)) {
112
+ validateInputFields(state, reportError, type);
113
+ validateInputObjectCircularRefs(type);
114
+ }
115
+ }
116
+ }
117
+ function validateName(reportError, name) {
118
+ if (name.startsWith('__')) {
119
+ reportError(`Name "${name}" must not begin with "__", which is reserved by GraphQL introspection.`);
120
+ }
121
+ }
122
+ function validateFields(state, reportError, type) {
123
+ const fields = type.fields;
124
+ const isRootType = type.name === state.schema.queryType ||
125
+ type.name === state.schema.mutationType ||
126
+ type.name === state.schema.subscriptionType;
127
+ if (fields.size === 0 && !isRootType) {
128
+ reportError(`Type ${type.name} must define one or more fields.`);
129
+ }
130
+ for (const field of fields.values()) {
131
+ validateName(reportError, field.name);
132
+ const fieldTypeName = (0, state_js_1.stripTypeModifiers)(field.type);
133
+ const fieldTypeExists = typeExists(state, fieldTypeName);
134
+ if (!fieldTypeExists) {
135
+ continue;
136
+ }
137
+ if (!isOutputType(state, fieldTypeName)) {
138
+ reportError(`The type of "${type.name}.${field.name}" must be Output Type but got: "${field.type}".`);
139
+ }
140
+ for (const arg of field.args.values()) {
141
+ const argName = arg.name;
142
+ validateName(reportError, argName);
143
+ const argTypeName = (0, state_js_1.stripTypeModifiers)(arg.type);
144
+ const argTypeExists = typeExists(state, argTypeName);
145
+ if (!argTypeExists) {
146
+ continue;
147
+ }
148
+ if (!isInputType(state, argTypeName)) {
149
+ const isList = arg.type.endsWith(']');
150
+ const isNonNull = arg.type.endsWith('!');
151
+ const extra = isList ? ', a ListType' : isNonNull ? ', a NonNullType' : '';
152
+ reportError(`The type of "${type.name}.${field.name}(${argName}:)" must be Input Type but got "${arg.type}"${extra}.`);
153
+ }
154
+ if (isRequiredArgument(arg) && arg.deprecated?.deprecated) {
155
+ reportError(`Required argument ${type.name}.${field.name}(${argName}:) cannot be deprecated.`);
156
+ }
157
+ if (typeof arg.defaultValue !== 'undefined' &&
158
+ !isValidateDefaultValue(state, reportError, arg.type, (0, graphql_1.parseValue)(arg.defaultValue))) {
159
+ reportError(`Invalid default value (got: ${arg.defaultValue}) provided for argument ${type.name}.${field.name}(${arg.name}:) of type ${arg.type}.`);
160
+ }
161
+ }
162
+ }
163
+ }
164
+ function isValidateDefaultValue(state, reportError, inputTypePrinted, value) {
165
+ if ((0, state_js_1.isNonNull)(inputTypePrinted)) {
166
+ if (value.kind === graphql_1.Kind.NULL) {
167
+ return false;
168
+ }
169
+ return isValidateDefaultValue(state, reportError, (0, state_js_1.stripNonNull)(inputTypePrinted), value);
170
+ }
171
+ if (value.kind === graphql_1.Kind.NULL) {
172
+ return true;
173
+ }
174
+ const inputTypeName = (0, state_js_1.stripTypeModifiers)(inputTypePrinted);
175
+ const inputType = state.types.get(inputTypeName);
176
+ if (inputType && isScalarType(inputType)) {
177
+ return true;
178
+ }
179
+ if ((0, state_js_1.isList)(inputTypePrinted)) {
180
+ if (value.kind === graphql_1.Kind.LIST) {
181
+ return value.values.every(val => isValidateDefaultValue(state, reportError, (0, state_js_1.stripList)(inputTypePrinted), val));
182
+ }
183
+ return isValidateDefaultValue(state, reportError, (0, state_js_1.stripList)(inputTypePrinted), value);
184
+ }
185
+ if (specifiedScalars.has(inputTypeName)) {
186
+ const specifiedScalar = graphql_1.specifiedScalarTypes.find(t => t.name === inputTypeName);
187
+ try {
188
+ specifiedScalar.parseLiteral(value);
189
+ return true;
190
+ }
191
+ catch (error) {
192
+ return false;
193
+ }
194
+ }
195
+ if (!inputType) {
196
+ return true;
197
+ }
198
+ if (isInputObjectType(inputType)) {
199
+ if (value.kind !== graphql_1.Kind.OBJECT) {
200
+ return false;
201
+ }
202
+ const fields = inputType.fields;
203
+ for (const astField of value.fields) {
204
+ const field = fields.get(astField.name.value);
205
+ if (!field) {
206
+ return false;
207
+ }
208
+ if (!isValidateDefaultValue(state, reportError, field.type, astField.value)) {
209
+ return false;
210
+ }
211
+ }
212
+ return true;
213
+ }
214
+ if (isEnumType(inputType)) {
215
+ if (value.kind !== graphql_1.Kind.ENUM && value.kind !== graphql_1.Kind.STRING) {
216
+ return false;
217
+ }
218
+ return inputType.values.has(value.value);
219
+ }
220
+ return false;
221
+ }
222
+ function validateUnionMembers(state, reportError, union) {
223
+ const memberTypes = union.members;
224
+ if (memberTypes.size === 0) {
225
+ reportError(`Union type ${union.name} must define one or more member types.`);
226
+ }
227
+ const includedTypeNames = new Set();
228
+ for (const memberType of memberTypes) {
229
+ if (includedTypeNames.has(memberType)) {
230
+ reportError(`Union type ${union.name} can only include type ${memberType} once.`);
231
+ continue;
232
+ }
233
+ includedTypeNames.add(memberType);
234
+ const type = state.types.get(memberType);
235
+ if (!type || !isObjectType(type)) {
236
+ reportError(`Union type ${union.name} can only include Object types, ` +
237
+ `it cannot include ${memberType}.`);
238
+ }
239
+ }
240
+ }
241
+ function validateEnumValues(reportError, enumType) {
242
+ const enumValues = enumType.values;
243
+ if (enumValues.size === 0) {
244
+ reportError(`Enum type ${enumType.name} must define one or more values.`);
245
+ }
246
+ for (const enumValue of enumValues.keys()) {
247
+ validateName(reportError, enumValue);
248
+ }
249
+ }
250
+ function validateInputFields(state, reportError, inputObj) {
251
+ const fields = inputObj.fields;
252
+ if (fields.size === 0) {
253
+ reportError(`Input Object type ${inputObj.name} must define one or more fields.`);
254
+ }
255
+ for (const field of fields.values()) {
256
+ validateName(reportError, field.name);
257
+ const fieldTypeName = (0, state_js_1.stripTypeModifiers)(field.type);
258
+ const fieldTypeExists = typeExists(state, fieldTypeName);
259
+ if (!fieldTypeExists) {
260
+ continue;
261
+ }
262
+ if (!isInputType(state, fieldTypeName)) {
263
+ const isList = field.type.endsWith(']');
264
+ const isNonNull = field.type.endsWith('!');
265
+ const extra = isList ? ', a ListType' : isNonNull ? ', a NonNullType' : '';
266
+ reportError(`The type of ${inputObj.name}.${field.name} must be Input Type but got "${field.type}"${extra}.`);
267
+ }
268
+ if (isRequiredInputField(field) && field.deprecated?.deprecated) {
269
+ reportError(`Required input field ${inputObj.name}.${field.name} cannot be deprecated.`);
270
+ }
271
+ if (typeof field.defaultValue !== 'undefined' &&
272
+ !isValidateDefaultValue(state, reportError, field.type, (0, graphql_1.parseValue)(field.defaultValue))) {
273
+ reportError(`Invalid default value (got: ${field.defaultValue}) provided for input field ${inputObj.name}.${field.name} of type ${field.type}.`);
274
+ }
275
+ }
276
+ }
277
+ function validateInterfaces(state, implementationsMap, reportError, type) {
278
+ const ifaceTypeNames = new Set();
279
+ for (const iface of type.interfaces) {
280
+ const interfaceType = state.types.get(iface);
281
+ if (!interfaceType) {
282
+ continue;
283
+ }
284
+ if (!isInterfaceType(interfaceType)) {
285
+ reportError(`Type ${type.name} must only implement Interface types, it cannot implement ${iface}.`);
286
+ continue;
287
+ }
288
+ if (type.name === iface) {
289
+ reportError(`Type ${type.name} cannot implement itself because it would create a circular reference.`);
290
+ continue;
291
+ }
292
+ if (ifaceTypeNames.has(iface)) {
293
+ reportError(`Type ${type.name} can only implement ${iface} once.`);
294
+ continue;
295
+ }
296
+ ifaceTypeNames.add(iface);
297
+ validateTypeImplementsAncestors(reportError, type, interfaceType);
298
+ validateTypeImplementsInterface(state, implementationsMap, reportError, type, interfaceType);
299
+ }
300
+ }
301
+ function validateTypeImplementsAncestors(reportError, type, interfaceType) {
302
+ const ifaceInterfaces = type.interfaces;
303
+ for (const transitive of interfaceType.interfaces) {
304
+ if (!ifaceInterfaces.has(transitive)) {
305
+ reportError(transitive === type.name
306
+ ? `Type ${type.name} cannot implement ${interfaceType.name} because it would create a circular reference.`
307
+ : `Type ${type.name} must implement ${transitive} because it is implemented by ${interfaceType.name}.`);
308
+ }
309
+ }
310
+ }
311
+ function validateTypeImplementsInterface(state, implementationsMap, reportError, type, interfaceType) {
312
+ const typeFieldMap = type.fields;
313
+ for (const ifaceField of interfaceType.fields.values()) {
314
+ const fieldName = ifaceField.name;
315
+ const typeField = typeFieldMap.get(fieldName);
316
+ if (typeField == null) {
317
+ reportError(`Interface field ${interfaceType.name}.${fieldName} expected but ${type.name} does not provide it.`);
318
+ continue;
319
+ }
320
+ if (!isTypeSubTypeOf(state, implementationsMap, typeField.type, ifaceField.type)) {
321
+ reportError(`Interface field ${interfaceType.name}.${fieldName} expects type ` +
322
+ `${ifaceField.type} but ${type.name}.${fieldName} is type ${typeField.type}.`);
323
+ }
324
+ for (const ifaceArg of ifaceField.args.values()) {
325
+ const argName = ifaceArg.name;
326
+ const typeArg = typeField.args.get(argName);
327
+ if (!typeArg) {
328
+ reportError(`Interface field argument ${interfaceType.name}.${fieldName}(${argName}:) expected but ${type.name}.${fieldName} does not provide it.`);
329
+ continue;
330
+ }
331
+ if (ifaceArg.type !== typeArg.type) {
332
+ reportError(`Interface field argument ${interfaceType.name}.${fieldName}(${argName}:) ` +
333
+ `expects type ${ifaceArg.type} but ` +
334
+ `${type.name}.${fieldName}(${argName}:) is type ` +
335
+ `${typeArg.type}.`);
336
+ }
337
+ }
338
+ for (const typeArg of typeField.args.values()) {
339
+ const argName = typeArg.name;
340
+ const ifaceArg = ifaceField.args.get(argName);
341
+ if (!ifaceArg && isRequiredArgument(typeArg)) {
342
+ reportError(`Object field ${type.name}.${fieldName} includes required argument ${argName} that is missing from the Interface field ${interfaceType.name}.${fieldName}.`);
343
+ }
344
+ }
345
+ }
346
+ }
347
+ function isTypeSubTypeOf(state, implementationsMap, maybeSubTypeName, superTypeName) {
348
+ if (maybeSubTypeName === superTypeName) {
349
+ return true;
350
+ }
351
+ if ((0, state_js_1.isNonNull)(superTypeName)) {
352
+ if ((0, state_js_1.isNonNull)(maybeSubTypeName)) {
353
+ return isTypeSubTypeOf(state, implementationsMap, (0, state_js_1.stripNonNull)(maybeSubTypeName), (0, state_js_1.stripNonNull)(superTypeName));
354
+ }
355
+ return false;
356
+ }
357
+ if ((0, state_js_1.isNonNull)(maybeSubTypeName)) {
358
+ return isTypeSubTypeOf(state, implementationsMap, (0, state_js_1.stripNonNull)(maybeSubTypeName), superTypeName);
359
+ }
360
+ if ((0, state_js_1.isList)(superTypeName)) {
361
+ if ((0, state_js_1.isList)(maybeSubTypeName)) {
362
+ return isTypeSubTypeOf(state, implementationsMap, (0, state_js_1.stripList)(maybeSubTypeName), (0, state_js_1.stripList)(superTypeName));
363
+ }
364
+ return false;
365
+ }
366
+ if ((0, state_js_1.isList)(maybeSubTypeName)) {
367
+ return false;
368
+ }
369
+ const superType = state.types.get(superTypeName);
370
+ const maybeSubType = state.types.get(maybeSubTypeName);
371
+ if (!superType || !maybeSubType) {
372
+ return false;
373
+ }
374
+ return (isAbstractType(superType) &&
375
+ (isInterfaceType(maybeSubType) || isObjectType(maybeSubType)) &&
376
+ isSubType(implementationsMap, superType, maybeSubType));
377
+ }
378
+ exports.isTypeSubTypeOf = isTypeSubTypeOf;
379
+ function isSubType(implementationsMap, abstractType, maybeSubType) {
380
+ if (isUnionType(abstractType)) {
381
+ return abstractType.members.has(maybeSubType.name);
382
+ }
383
+ return implementationsMap.get(abstractType.name)?.has(maybeSubType.name) ?? false;
384
+ }
385
+ function createInputObjectCircularRefsValidator(state, reportError) {
386
+ const visitedTypes = new Set();
387
+ const fieldPath = [];
388
+ const fieldPathIndexByTypeName = Object.create(null);
389
+ return detectCycleRecursive;
390
+ function detectCycleRecursive(inputObj) {
391
+ if (visitedTypes.has(inputObj)) {
392
+ return;
393
+ }
394
+ visitedTypes.add(inputObj);
395
+ fieldPathIndexByTypeName[inputObj.name] = fieldPath.length;
396
+ for (const field of inputObj.fields.values()) {
397
+ if ((0, state_js_1.isNonNull)(field.type)) {
398
+ const fieldType = state.types.get((0, state_js_1.stripNonNull)(field.type));
399
+ if (fieldType && isInputObjectType(fieldType)) {
400
+ const cycleIndex = fieldPathIndexByTypeName[fieldType.name];
401
+ fieldPath.push(field.name);
402
+ if (cycleIndex === undefined) {
403
+ detectCycleRecursive(fieldType);
404
+ }
405
+ else {
406
+ const cyclePath = fieldPath.slice(cycleIndex);
407
+ reportError(`Cannot reference Input Object "${fieldType.name}" within itself through a series of non-null fields: "${cyclePath.join('.')}".`);
408
+ }
409
+ fieldPath.pop();
410
+ }
411
+ }
412
+ }
413
+ fieldPathIndexByTypeName[inputObj.name] = undefined;
414
+ }
415
+ }
416
+ function isIntrospectionType(typeName) {
417
+ return graphql_1.introspectionTypes.some(t => t.name === typeName);
418
+ }
419
+ function isAbstractType(type) {
420
+ return isInterfaceType(type) || isUnionType(type);
421
+ }
422
+ function isRequiredArgument(arg) {
423
+ return (0, state_js_1.isNonNull)(arg.type) && arg.defaultValue === undefined;
424
+ }
425
+ function isRequiredInputField(arg) {
426
+ return (0, state_js_1.isNonNull)(arg.type) && arg.defaultValue === undefined;
427
+ }
428
+ function isOutputType(state, typeName) {
429
+ const type = state.types.get(typeName);
430
+ if (!type) {
431
+ if (specifiedScalars.has(typeName)) {
432
+ return true;
433
+ }
434
+ throw new Error(`Expected to find ${typeName} type`);
435
+ }
436
+ return !isInputObjectType(type);
437
+ }
438
+ function isInputType(state, typeName) {
439
+ const type = state.types.get(typeName);
440
+ if (!type) {
441
+ if (specifiedScalars.has(typeName)) {
442
+ return true;
443
+ }
444
+ throw new Error(`Expected to find ${typeName} type`);
445
+ }
446
+ return isScalarType(type) || isEnumType(type) || isInputObjectType(type);
447
+ }
448
+ exports.isInputType = isInputType;
449
+ function typeExists(state, typeName) {
450
+ return state.types.has(typeName) || specifiedScalars.has(typeName);
451
+ }
452
+ exports.typeExists = typeExists;
453
+ function isInputObjectType(type) {
454
+ return type.kind === state_js_2.TypeKind.INPUT_OBJECT;
455
+ }
456
+ exports.isInputObjectType = isInputObjectType;
457
+ function isScalarType(type) {
458
+ return type.kind === state_js_2.TypeKind.SCALAR;
459
+ }
460
+ exports.isScalarType = isScalarType;
461
+ function isEnumType(type) {
462
+ return type.kind === state_js_2.TypeKind.ENUM;
463
+ }
464
+ exports.isEnumType = isEnumType;
465
+ function isObjectType(type) {
466
+ return type.kind === state_js_2.TypeKind.OBJECT;
467
+ }
468
+ exports.isObjectType = isObjectType;
469
+ function isInterfaceType(type) {
470
+ return type.kind === state_js_2.TypeKind.INTERFACE;
471
+ }
472
+ exports.isInterfaceType = isInterfaceType;
473
+ function isUnionType(type) {
474
+ return type.kind === state_js_2.TypeKind.UNION;
475
+ }
476
+ exports.isUnionType = isUnionType;