@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.
- package/LICENSE +18 -0
- package/cjs/compose.js +85 -0
- package/cjs/graphql/helpers.js +32 -0
- package/cjs/graphql/printer.js +248 -0
- package/cjs/graphql/type-node-info.js +142 -0
- package/cjs/index.js +22 -0
- package/cjs/package.json +1 -0
- package/cjs/specifications/federation.js +211 -0
- package/cjs/specifications/inaccessible.js +10 -0
- package/cjs/specifications/join.js +35 -0
- package/cjs/specifications/link.js +222 -0
- package/cjs/specifications/tag.js +12 -0
- package/cjs/subgraph/helpers.js +255 -0
- package/cjs/subgraph/state.js +1154 -0
- package/cjs/subgraph/validation/rules/elements/compose-directive.js +41 -0
- package/cjs/subgraph/validation/rules/elements/extends.js +34 -0
- package/cjs/subgraph/validation/rules/elements/external.js +57 -0
- package/cjs/subgraph/validation/rules/elements/field-set.js +37 -0
- package/cjs/subgraph/validation/rules/elements/inaccessible.js +112 -0
- package/cjs/subgraph/validation/rules/elements/key.js +148 -0
- package/cjs/subgraph/validation/rules/elements/override.js +56 -0
- package/cjs/subgraph/validation/rules/elements/provides.js +173 -0
- package/cjs/subgraph/validation/rules/elements/requires.js +119 -0
- package/cjs/subgraph/validation/rules/elements/shareable.js +43 -0
- package/cjs/subgraph/validation/rules/elements/tag.js +120 -0
- package/cjs/subgraph/validation/rules/known-argument-names-on-directives-rule.js +34 -0
- package/cjs/subgraph/validation/rules/known-directives-rule.js +105 -0
- package/cjs/subgraph/validation/rules/known-federation-directive-rule.js +34 -0
- package/cjs/subgraph/validation/rules/known-root-type-rule.js +25 -0
- package/cjs/subgraph/validation/rules/known-type-names-rule.js +34 -0
- package/cjs/subgraph/validation/rules/lone-schema-definition-rule.js +20 -0
- package/cjs/subgraph/validation/rules/provided-arguments-on-directives-rule.js +104 -0
- package/cjs/subgraph/validation/rules/provided-required-arguments-on-directives-rule.js +46 -0
- package/cjs/subgraph/validation/rules/query-root-type-inaccessible-rule.js +33 -0
- package/cjs/subgraph/validation/rules/reserved-subgraph-name-rule.js +15 -0
- package/cjs/subgraph/validation/rules/root-type-used-rule.js +59 -0
- package/cjs/subgraph/validation/rules/unique-argument-definition-names-rule.js +42 -0
- package/cjs/subgraph/validation/rules/unique-argument-names-rule.js +27 -0
- package/cjs/subgraph/validation/rules/unique-directive-names-rule.js +24 -0
- package/cjs/subgraph/validation/rules/unique-directives-per-location-rule.js +52 -0
- package/cjs/subgraph/validation/rules/unique-enum-value-names-rule.js +33 -0
- package/cjs/subgraph/validation/rules/unique-field-definition-names-rule.js +37 -0
- package/cjs/subgraph/validation/rules/unique-input-field-names-rule.js +37 -0
- package/cjs/subgraph/validation/rules/unique-operation-types-rule.js +29 -0
- package/cjs/subgraph/validation/rules/unique-type-names-rule.js +29 -0
- package/cjs/subgraph/validation/validate-state.js +476 -0
- package/cjs/subgraph/validation/validate-subgraph.js +329 -0
- package/cjs/subgraph/validation/validation-context.js +267 -0
- package/cjs/supergraph/composition/ast.js +779 -0
- package/cjs/supergraph/composition/common.js +7 -0
- package/cjs/supergraph/composition/directive.js +93 -0
- package/cjs/supergraph/composition/enum-type.js +132 -0
- package/cjs/supergraph/composition/input-object-type.js +119 -0
- package/cjs/supergraph/composition/interface-type.js +226 -0
- package/cjs/supergraph/composition/object-type.js +380 -0
- package/cjs/supergraph/composition/scalar-type.js +63 -0
- package/cjs/supergraph/composition/union-type.js +64 -0
- package/cjs/supergraph/composition/visitor.js +62 -0
- package/cjs/supergraph/state.js +249 -0
- package/cjs/supergraph/validation/rules/default-value-uses-inaccessible-rule.js +35 -0
- package/cjs/supergraph/validation/rules/directive-composition-rule.js +98 -0
- package/cjs/supergraph/validation/rules/enum-values-rule.js +59 -0
- package/cjs/supergraph/validation/rules/extension-with-base.js +31 -0
- package/cjs/supergraph/validation/rules/external-argument-missing-rule.js +32 -0
- package/cjs/supergraph/validation/rules/external-missing-on-base-rule.js +48 -0
- package/cjs/supergraph/validation/rules/external-type-mismatch-rule.js +52 -0
- package/cjs/supergraph/validation/rules/field-argument-default-mismatch-rule.js +40 -0
- package/cjs/supergraph/validation/rules/field-arguments-of-the-same-type-rule.js +49 -0
- package/cjs/supergraph/validation/rules/fields-of-the-same-type-rule.js +89 -0
- package/cjs/supergraph/validation/rules/input-field-default-mismatch-rule.js +40 -0
- package/cjs/supergraph/validation/rules/input-object-values-rule.js +25 -0
- package/cjs/supergraph/validation/rules/interface-key-missing-implementation-type.js +46 -0
- package/cjs/supergraph/validation/rules/invalid-field-sharing-rule.js +45 -0
- package/cjs/supergraph/validation/rules/only-inaccessible-children-rule.js +40 -0
- package/cjs/supergraph/validation/rules/override-source-has-override.js +36 -0
- package/cjs/supergraph/validation/rules/referenced-inaccessible-rule.js +44 -0
- package/cjs/supergraph/validation/rules/required-argument-missing-in-some-subgraph-rule.js +32 -0
- package/cjs/supergraph/validation/rules/required-input-field-missing-in-some-subgraph-rule.js +32 -0
- package/cjs/supergraph/validation/rules/required-query-rule.js +14 -0
- package/cjs/supergraph/validation/rules/satisfiablity-rule.js +866 -0
- package/cjs/supergraph/validation/rules/subgraph-name-rule.js +18 -0
- package/cjs/supergraph/validation/rules/types-of-the-same-kind-rule.js +54 -0
- package/cjs/supergraph/validation/validate-supergraph.js +77 -0
- package/cjs/supergraph/validation/validation-context.js +25 -0
- package/cjs/types.js +0 -0
- package/cjs/utils/dependency-graph.js +227 -0
- package/cjs/utils/format.js +27 -0
- package/cjs/utils/helpers.js +7 -0
- package/cjs/utils/state.js +23 -0
- package/cjs/validate.js +117 -0
- package/esm/compose.js +78 -0
- package/esm/graphql/helpers.js +27 -0
- package/esm/graphql/printer.js +244 -0
- package/esm/graphql/type-node-info.js +137 -0
- package/esm/index.js +4 -0
- package/esm/specifications/federation.js +204 -0
- package/esm/specifications/inaccessible.js +7 -0
- package/esm/specifications/join.js +32 -0
- package/esm/specifications/link.js +210 -0
- package/esm/specifications/tag.js +9 -0
- package/esm/subgraph/helpers.js +245 -0
- package/esm/subgraph/state.js +1148 -0
- package/esm/subgraph/validation/rules/elements/compose-directive.js +37 -0
- package/esm/subgraph/validation/rules/elements/extends.js +30 -0
- package/esm/subgraph/validation/rules/elements/external.js +53 -0
- package/esm/subgraph/validation/rules/elements/field-set.js +33 -0
- package/esm/subgraph/validation/rules/elements/inaccessible.js +108 -0
- package/esm/subgraph/validation/rules/elements/key.js +144 -0
- package/esm/subgraph/validation/rules/elements/override.js +52 -0
- package/esm/subgraph/validation/rules/elements/provides.js +169 -0
- package/esm/subgraph/validation/rules/elements/requires.js +115 -0
- package/esm/subgraph/validation/rules/elements/shareable.js +39 -0
- package/esm/subgraph/validation/rules/elements/tag.js +116 -0
- package/esm/subgraph/validation/rules/known-argument-names-on-directives-rule.js +30 -0
- package/esm/subgraph/validation/rules/known-directives-rule.js +101 -0
- package/esm/subgraph/validation/rules/known-federation-directive-rule.js +30 -0
- package/esm/subgraph/validation/rules/known-root-type-rule.js +21 -0
- package/esm/subgraph/validation/rules/known-type-names-rule.js +30 -0
- package/esm/subgraph/validation/rules/lone-schema-definition-rule.js +16 -0
- package/esm/subgraph/validation/rules/provided-arguments-on-directives-rule.js +100 -0
- package/esm/subgraph/validation/rules/provided-required-arguments-on-directives-rule.js +42 -0
- package/esm/subgraph/validation/rules/query-root-type-inaccessible-rule.js +29 -0
- package/esm/subgraph/validation/rules/reserved-subgraph-name-rule.js +11 -0
- package/esm/subgraph/validation/rules/root-type-used-rule.js +55 -0
- package/esm/subgraph/validation/rules/unique-argument-definition-names-rule.js +38 -0
- package/esm/subgraph/validation/rules/unique-argument-names-rule.js +23 -0
- package/esm/subgraph/validation/rules/unique-directive-names-rule.js +20 -0
- package/esm/subgraph/validation/rules/unique-directives-per-location-rule.js +48 -0
- package/esm/subgraph/validation/rules/unique-enum-value-names-rule.js +29 -0
- package/esm/subgraph/validation/rules/unique-field-definition-names-rule.js +33 -0
- package/esm/subgraph/validation/rules/unique-input-field-names-rule.js +33 -0
- package/esm/subgraph/validation/rules/unique-operation-types-rule.js +25 -0
- package/esm/subgraph/validation/rules/unique-type-names-rule.js +25 -0
- package/esm/subgraph/validation/validate-state.js +463 -0
- package/esm/subgraph/validation/validate-subgraph.js +323 -0
- package/esm/subgraph/validation/validation-context.js +262 -0
- package/esm/supergraph/composition/ast.js +765 -0
- package/esm/supergraph/composition/common.js +3 -0
- package/esm/supergraph/composition/directive.js +89 -0
- package/esm/supergraph/composition/enum-type.js +128 -0
- package/esm/supergraph/composition/input-object-type.js +115 -0
- package/esm/supergraph/composition/interface-type.js +222 -0
- package/esm/supergraph/composition/object-type.js +375 -0
- package/esm/supergraph/composition/scalar-type.js +59 -0
- package/esm/supergraph/composition/union-type.js +60 -0
- package/esm/supergraph/composition/visitor.js +58 -0
- package/esm/supergraph/state.js +245 -0
- package/esm/supergraph/validation/rules/default-value-uses-inaccessible-rule.js +31 -0
- package/esm/supergraph/validation/rules/directive-composition-rule.js +94 -0
- package/esm/supergraph/validation/rules/enum-values-rule.js +55 -0
- package/esm/supergraph/validation/rules/extension-with-base.js +27 -0
- package/esm/supergraph/validation/rules/external-argument-missing-rule.js +28 -0
- package/esm/supergraph/validation/rules/external-missing-on-base-rule.js +44 -0
- package/esm/supergraph/validation/rules/external-type-mismatch-rule.js +48 -0
- package/esm/supergraph/validation/rules/field-argument-default-mismatch-rule.js +36 -0
- package/esm/supergraph/validation/rules/field-arguments-of-the-same-type-rule.js +45 -0
- package/esm/supergraph/validation/rules/fields-of-the-same-type-rule.js +85 -0
- package/esm/supergraph/validation/rules/input-field-default-mismatch-rule.js +36 -0
- package/esm/supergraph/validation/rules/input-object-values-rule.js +21 -0
- package/esm/supergraph/validation/rules/interface-key-missing-implementation-type.js +42 -0
- package/esm/supergraph/validation/rules/invalid-field-sharing-rule.js +41 -0
- package/esm/supergraph/validation/rules/only-inaccessible-children-rule.js +36 -0
- package/esm/supergraph/validation/rules/override-source-has-override.js +32 -0
- package/esm/supergraph/validation/rules/referenced-inaccessible-rule.js +40 -0
- package/esm/supergraph/validation/rules/required-argument-missing-in-some-subgraph-rule.js +28 -0
- package/esm/supergraph/validation/rules/required-input-field-missing-in-some-subgraph-rule.js +28 -0
- package/esm/supergraph/validation/rules/required-query-rule.js +10 -0
- package/esm/supergraph/validation/rules/satisfiablity-rule.js +862 -0
- package/esm/supergraph/validation/rules/subgraph-name-rule.js +14 -0
- package/esm/supergraph/validation/rules/types-of-the-same-kind-rule.js +50 -0
- package/esm/supergraph/validation/validate-supergraph.js +73 -0
- package/esm/supergraph/validation/validation-context.js +21 -0
- package/esm/types.js +0 -0
- package/esm/utils/dependency-graph.js +222 -0
- package/esm/utils/format.js +23 -0
- package/esm/utils/helpers.js +3 -0
- package/esm/utils/state.js +15 -0
- package/esm/validate.js +113 -0
- package/package.json +46 -0
- package/typings/compose.d.cts +16 -0
- package/typings/compose.d.ts +16 -0
- package/typings/graphql/helpers.d.cts +4 -0
- package/typings/graphql/helpers.d.ts +4 -0
- package/typings/graphql/printer.d.cts +3 -0
- package/typings/graphql/printer.d.ts +3 -0
- package/typings/graphql/type-node-info.d.cts +19 -0
- package/typings/graphql/type-node-info.d.ts +19 -0
- package/typings/index.d.cts +5 -0
- package/typings/index.d.ts +5 -0
- package/typings/specifications/federation.d.cts +45 -0
- package/typings/specifications/federation.d.ts +45 -0
- package/typings/specifications/inaccessible.d.cts +4 -0
- package/typings/specifications/inaccessible.d.ts +4 -0
- package/typings/specifications/join.d.cts +2 -0
- package/typings/specifications/join.d.ts +2 -0
- package/typings/specifications/link.d.cts +61 -0
- package/typings/specifications/link.d.ts +61 -0
- package/typings/specifications/tag.d.cts +4 -0
- package/typings/specifications/tag.d.ts +4 -0
- package/typings/subgraph/helpers.d.cts +44 -0
- package/typings/subgraph/helpers.d.ts +44 -0
- package/typings/subgraph/state.d.cts +322 -0
- package/typings/subgraph/state.d.ts +322 -0
- package/typings/subgraph/validation/rules/elements/compose-directive.d.cts +4 -0
- package/typings/subgraph/validation/rules/elements/compose-directive.d.ts +4 -0
- package/typings/subgraph/validation/rules/elements/extends.d.cts +4 -0
- package/typings/subgraph/validation/rules/elements/extends.d.ts +4 -0
- package/typings/subgraph/validation/rules/elements/external.d.cts +4 -0
- package/typings/subgraph/validation/rules/elements/external.d.ts +4 -0
- package/typings/subgraph/validation/rules/elements/field-set.d.cts +4 -0
- package/typings/subgraph/validation/rules/elements/field-set.d.ts +4 -0
- package/typings/subgraph/validation/rules/elements/inaccessible.d.cts +4 -0
- package/typings/subgraph/validation/rules/elements/inaccessible.d.ts +4 -0
- package/typings/subgraph/validation/rules/elements/key.d.cts +4 -0
- package/typings/subgraph/validation/rules/elements/key.d.ts +4 -0
- package/typings/subgraph/validation/rules/elements/override.d.cts +4 -0
- package/typings/subgraph/validation/rules/elements/override.d.ts +4 -0
- package/typings/subgraph/validation/rules/elements/provides.d.cts +4 -0
- package/typings/subgraph/validation/rules/elements/provides.d.ts +4 -0
- package/typings/subgraph/validation/rules/elements/requires.d.cts +4 -0
- package/typings/subgraph/validation/rules/elements/requires.d.ts +4 -0
- package/typings/subgraph/validation/rules/elements/shareable.d.cts +4 -0
- package/typings/subgraph/validation/rules/elements/shareable.d.ts +4 -0
- package/typings/subgraph/validation/rules/elements/tag.d.cts +4 -0
- package/typings/subgraph/validation/rules/elements/tag.d.ts +4 -0
- package/typings/subgraph/validation/rules/known-argument-names-on-directives-rule.d.cts +6 -0
- package/typings/subgraph/validation/rules/known-argument-names-on-directives-rule.d.ts +6 -0
- package/typings/subgraph/validation/rules/known-directives-rule.d.cts +6 -0
- package/typings/subgraph/validation/rules/known-directives-rule.d.ts +6 -0
- package/typings/subgraph/validation/rules/known-federation-directive-rule.d.cts +4 -0
- package/typings/subgraph/validation/rules/known-federation-directive-rule.d.ts +4 -0
- package/typings/subgraph/validation/rules/known-root-type-rule.d.cts +4 -0
- package/typings/subgraph/validation/rules/known-root-type-rule.d.ts +4 -0
- package/typings/subgraph/validation/rules/known-type-names-rule.d.cts +4 -0
- package/typings/subgraph/validation/rules/known-type-names-rule.d.ts +4 -0
- package/typings/subgraph/validation/rules/lone-schema-definition-rule.d.cts +5 -0
- package/typings/subgraph/validation/rules/lone-schema-definition-rule.d.ts +5 -0
- package/typings/subgraph/validation/rules/provided-arguments-on-directives-rule.d.cts +4 -0
- package/typings/subgraph/validation/rules/provided-arguments-on-directives-rule.d.ts +4 -0
- package/typings/subgraph/validation/rules/provided-required-arguments-on-directives-rule.d.cts +4 -0
- package/typings/subgraph/validation/rules/provided-required-arguments-on-directives-rule.d.ts +4 -0
- package/typings/subgraph/validation/rules/query-root-type-inaccessible-rule.d.cts +4 -0
- package/typings/subgraph/validation/rules/query-root-type-inaccessible-rule.d.ts +4 -0
- package/typings/subgraph/validation/rules/reserved-subgraph-name-rule.d.cts +4 -0
- package/typings/subgraph/validation/rules/reserved-subgraph-name-rule.d.ts +4 -0
- package/typings/subgraph/validation/rules/root-type-used-rule.d.cts +4 -0
- package/typings/subgraph/validation/rules/root-type-used-rule.d.ts +4 -0
- package/typings/subgraph/validation/rules/unique-argument-definition-names-rule.d.cts +5 -0
- package/typings/subgraph/validation/rules/unique-argument-definition-names-rule.d.ts +5 -0
- package/typings/subgraph/validation/rules/unique-argument-names-rule.d.cts +5 -0
- package/typings/subgraph/validation/rules/unique-argument-names-rule.d.ts +5 -0
- package/typings/subgraph/validation/rules/unique-directive-names-rule.d.cts +5 -0
- package/typings/subgraph/validation/rules/unique-directive-names-rule.d.ts +5 -0
- package/typings/subgraph/validation/rules/unique-directives-per-location-rule.d.cts +6 -0
- package/typings/subgraph/validation/rules/unique-directives-per-location-rule.d.ts +6 -0
- package/typings/subgraph/validation/rules/unique-enum-value-names-rule.d.cts +5 -0
- package/typings/subgraph/validation/rules/unique-enum-value-names-rule.d.ts +5 -0
- package/typings/subgraph/validation/rules/unique-field-definition-names-rule.d.cts +5 -0
- package/typings/subgraph/validation/rules/unique-field-definition-names-rule.d.ts +5 -0
- package/typings/subgraph/validation/rules/unique-input-field-names-rule.d.cts +5 -0
- package/typings/subgraph/validation/rules/unique-input-field-names-rule.d.ts +5 -0
- package/typings/subgraph/validation/rules/unique-operation-types-rule.d.cts +5 -0
- package/typings/subgraph/validation/rules/unique-operation-types-rule.d.ts +5 -0
- package/typings/subgraph/validation/rules/unique-type-names-rule.d.cts +5 -0
- package/typings/subgraph/validation/rules/unique-type-names-rule.d.ts +5 -0
- package/typings/subgraph/validation/validate-state.d.cts +13 -0
- package/typings/subgraph/validation/validate-state.d.ts +13 -0
- package/typings/subgraph/validation/validate-subgraph.d.cts +43 -0
- package/typings/subgraph/validation/validate-subgraph.d.ts +43 -0
- package/typings/subgraph/validation/validation-context.d.cts +182 -0
- package/typings/subgraph/validation/validation-context.d.ts +182 -0
- package/typings/supergraph/composition/ast.d.cts +216 -0
- package/typings/supergraph/composition/ast.d.ts +216 -0
- package/typings/supergraph/composition/common.d.cts +19 -0
- package/typings/supergraph/composition/common.d.ts +19 -0
- package/typings/supergraph/composition/directive.d.cts +32 -0
- package/typings/supergraph/composition/directive.d.ts +32 -0
- package/typings/supergraph/composition/enum-type.d.cts +32 -0
- package/typings/supergraph/composition/enum-type.d.ts +32 -0
- package/typings/supergraph/composition/input-object-type.d.cts +32 -0
- package/typings/supergraph/composition/input-object-type.d.ts +32 -0
- package/typings/supergraph/composition/interface-type.d.cts +61 -0
- package/typings/supergraph/composition/interface-type.d.ts +61 -0
- package/typings/supergraph/composition/object-type.d.cts +79 -0
- package/typings/supergraph/composition/object-type.d.ts +79 -0
- package/typings/supergraph/composition/scalar-type.d.cts +20 -0
- package/typings/supergraph/composition/scalar-type.d.ts +20 -0
- package/typings/supergraph/composition/union-type.d.cts +17 -0
- package/typings/supergraph/composition/union-type.d.ts +17 -0
- package/typings/supergraph/composition/visitor.d.cts +18 -0
- package/typings/supergraph/composition/visitor.d.ts +18 -0
- package/typings/supergraph/state.d.cts +51 -0
- package/typings/supergraph/state.d.ts +51 -0
- package/typings/supergraph/validation/rules/default-value-uses-inaccessible-rule.d.cts +5 -0
- package/typings/supergraph/validation/rules/default-value-uses-inaccessible-rule.d.ts +5 -0
- package/typings/supergraph/validation/rules/directive-composition-rule.d.cts +5 -0
- package/typings/supergraph/validation/rules/directive-composition-rule.d.ts +5 -0
- package/typings/supergraph/validation/rules/enum-values-rule.d.cts +4 -0
- package/typings/supergraph/validation/rules/enum-values-rule.d.ts +4 -0
- package/typings/supergraph/validation/rules/extension-with-base.d.cts +4 -0
- package/typings/supergraph/validation/rules/extension-with-base.d.ts +4 -0
- package/typings/supergraph/validation/rules/external-argument-missing-rule.d.cts +4 -0
- package/typings/supergraph/validation/rules/external-argument-missing-rule.d.ts +4 -0
- package/typings/supergraph/validation/rules/external-missing-on-base-rule.d.cts +4 -0
- package/typings/supergraph/validation/rules/external-missing-on-base-rule.d.ts +4 -0
- package/typings/supergraph/validation/rules/external-type-mismatch-rule.d.cts +4 -0
- package/typings/supergraph/validation/rules/external-type-mismatch-rule.d.ts +4 -0
- package/typings/supergraph/validation/rules/field-argument-default-mismatch-rule.d.cts +4 -0
- package/typings/supergraph/validation/rules/field-argument-default-mismatch-rule.d.ts +4 -0
- package/typings/supergraph/validation/rules/field-arguments-of-the-same-type-rule.d.cts +4 -0
- package/typings/supergraph/validation/rules/field-arguments-of-the-same-type-rule.d.ts +4 -0
- package/typings/supergraph/validation/rules/fields-of-the-same-type-rule.d.cts +4 -0
- package/typings/supergraph/validation/rules/fields-of-the-same-type-rule.d.ts +4 -0
- package/typings/supergraph/validation/rules/input-field-default-mismatch-rule.d.cts +4 -0
- package/typings/supergraph/validation/rules/input-field-default-mismatch-rule.d.ts +4 -0
- package/typings/supergraph/validation/rules/input-object-values-rule.d.cts +4 -0
- package/typings/supergraph/validation/rules/input-object-values-rule.d.ts +4 -0
- package/typings/supergraph/validation/rules/interface-key-missing-implementation-type.d.cts +4 -0
- package/typings/supergraph/validation/rules/interface-key-missing-implementation-type.d.ts +4 -0
- package/typings/supergraph/validation/rules/invalid-field-sharing-rule.d.cts +4 -0
- package/typings/supergraph/validation/rules/invalid-field-sharing-rule.d.ts +4 -0
- package/typings/supergraph/validation/rules/only-inaccessible-children-rule.d.cts +4 -0
- package/typings/supergraph/validation/rules/only-inaccessible-children-rule.d.ts +4 -0
- package/typings/supergraph/validation/rules/override-source-has-override.d.cts +4 -0
- package/typings/supergraph/validation/rules/override-source-has-override.d.ts +4 -0
- package/typings/supergraph/validation/rules/referenced-inaccessible-rule.d.cts +5 -0
- package/typings/supergraph/validation/rules/referenced-inaccessible-rule.d.ts +5 -0
- package/typings/supergraph/validation/rules/required-argument-missing-in-some-subgraph-rule.d.cts +4 -0
- package/typings/supergraph/validation/rules/required-argument-missing-in-some-subgraph-rule.d.ts +4 -0
- package/typings/supergraph/validation/rules/required-input-field-missing-in-some-subgraph-rule.d.cts +4 -0
- package/typings/supergraph/validation/rules/required-input-field-missing-in-some-subgraph-rule.d.ts +4 -0
- package/typings/supergraph/validation/rules/required-query-rule.d.cts +3 -0
- package/typings/supergraph/validation/rules/required-query-rule.d.ts +3 -0
- package/typings/supergraph/validation/rules/satisfiablity-rule.d.cts +5 -0
- package/typings/supergraph/validation/rules/satisfiablity-rule.d.ts +5 -0
- package/typings/supergraph/validation/rules/subgraph-name-rule.d.cts +3 -0
- package/typings/supergraph/validation/rules/subgraph-name-rule.d.ts +3 -0
- package/typings/supergraph/validation/rules/types-of-the-same-kind-rule.d.cts +3 -0
- package/typings/supergraph/validation/rules/types-of-the-same-kind-rule.d.ts +3 -0
- package/typings/supergraph/validation/validate-supergraph.d.cts +6 -0
- package/typings/supergraph/validation/validate-supergraph.d.ts +6 -0
- package/typings/supergraph/validation/validation-context.d.cts +10 -0
- package/typings/supergraph/validation/validation-context.d.ts +10 -0
- package/typings/types.d.cts +7 -0
- package/typings/types.d.ts +7 -0
- package/typings/utils/dependency-graph.d.cts +31 -0
- package/typings/utils/dependency-graph.d.ts +31 -0
- package/typings/utils/format.d.cts +2 -0
- package/typings/utils/format.d.ts +2 -0
- package/typings/utils/helpers.d.cts +2 -0
- package/typings/utils/helpers.d.ts +2 -0
- package/typings/utils/state.d.cts +6 -0
- package/typings/utils/state.d.ts +6 -0
- package/typings/validate.d.cts +37 -0
- package/typings/validate.d.ts +37 -0
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { createObjectTypeNode } from './ast.js';
|
|
2
|
+
import { convertToConst } from './common.js';
|
|
3
|
+
export function isRealExtension(meta, version) {
|
|
4
|
+
return meta.extension
|
|
5
|
+
? meta.extensionType !== '@extends' && version === 'v1.0'
|
|
6
|
+
? false
|
|
7
|
+
: true
|
|
8
|
+
: false;
|
|
9
|
+
}
|
|
10
|
+
export function objectTypeBuilder() {
|
|
11
|
+
return {
|
|
12
|
+
visitSubgraphState(graph, state, typeName, type) {
|
|
13
|
+
const objectTypeState = getOrCreateObjectType(state, typeName);
|
|
14
|
+
type.tags.forEach(tag => objectTypeState.tags.add(tag));
|
|
15
|
+
if (type.inaccessible) {
|
|
16
|
+
objectTypeState.inaccessible = true;
|
|
17
|
+
}
|
|
18
|
+
const isDefinition = type.isDefinition && (graph.version === 'v1.0' ? type.extensionType !== '@extends' : true);
|
|
19
|
+
if (type.description && !objectTypeState.description) {
|
|
20
|
+
objectTypeState.description = type.description;
|
|
21
|
+
}
|
|
22
|
+
if (isDefinition) {
|
|
23
|
+
objectTypeState.hasDefinition = true;
|
|
24
|
+
}
|
|
25
|
+
if (type.ast.directives) {
|
|
26
|
+
type.ast.directives.forEach(directive => {
|
|
27
|
+
objectTypeState.ast.directives.push(directive);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
type.interfaces.forEach(interfaceName => objectTypeState.interfaces.add(interfaceName));
|
|
31
|
+
objectTypeState.byGraph.set(graph.id, {
|
|
32
|
+
extension: type.extension,
|
|
33
|
+
extensionType: type.extensionType,
|
|
34
|
+
external: type.external,
|
|
35
|
+
keys: type.keys,
|
|
36
|
+
inaccessible: type.inaccessible,
|
|
37
|
+
shareable: type.shareable,
|
|
38
|
+
interfaces: type.interfaces,
|
|
39
|
+
});
|
|
40
|
+
for (const field of type.fields.values()) {
|
|
41
|
+
const fieldState = getOrCreateField(objectTypeState, field.name, field.type);
|
|
42
|
+
field.tags.forEach(tag => fieldState.tags.add(tag));
|
|
43
|
+
const usedAsKey = type.fieldsUsedAsKeys.has(field.name);
|
|
44
|
+
if (usedAsKey) {
|
|
45
|
+
fieldState.usedAsKey = true;
|
|
46
|
+
}
|
|
47
|
+
const isExternal = graph.version === 'v1.0'
|
|
48
|
+
? field.external && isRealExtension(type, graph.version)
|
|
49
|
+
: field.external;
|
|
50
|
+
const shouldForceType = !usedAsKey && !isExternal && !fieldState.internal.seenNonExternal;
|
|
51
|
+
const shouldChangeType = shouldForceType ||
|
|
52
|
+
(!isExternal &&
|
|
53
|
+
!field.type.endsWith('!') &&
|
|
54
|
+
fieldState.type.endsWith('!'));
|
|
55
|
+
if (shouldChangeType) {
|
|
56
|
+
fieldState.type = field.type;
|
|
57
|
+
}
|
|
58
|
+
if (!fieldState.internal.seenNonExternal && !isExternal) {
|
|
59
|
+
fieldState.internal.seenNonExternal = true;
|
|
60
|
+
}
|
|
61
|
+
if (field.inaccessible) {
|
|
62
|
+
fieldState.inaccessible = true;
|
|
63
|
+
}
|
|
64
|
+
if (field.override) {
|
|
65
|
+
fieldState.override = field.override;
|
|
66
|
+
}
|
|
67
|
+
if (field.description && !fieldState.description) {
|
|
68
|
+
fieldState.description = field.description;
|
|
69
|
+
}
|
|
70
|
+
if (field.deprecated && !fieldState.deprecated) {
|
|
71
|
+
fieldState.deprecated = field.deprecated;
|
|
72
|
+
}
|
|
73
|
+
field.ast.directives.forEach(directive => {
|
|
74
|
+
fieldState.ast.directives.push(directive);
|
|
75
|
+
});
|
|
76
|
+
fieldState.byGraph.set(graph.id, {
|
|
77
|
+
type: field.type,
|
|
78
|
+
external: field.external,
|
|
79
|
+
inaccessible: field.inaccessible,
|
|
80
|
+
override: field.override,
|
|
81
|
+
provides: field.provides,
|
|
82
|
+
requires: field.requires,
|
|
83
|
+
provided: field.provided,
|
|
84
|
+
required: field.required,
|
|
85
|
+
shareable: field.shareable,
|
|
86
|
+
used: field.used,
|
|
87
|
+
usedAsKey,
|
|
88
|
+
});
|
|
89
|
+
for (const arg of field.args.values()) {
|
|
90
|
+
const argState = getOrCreateArg(fieldState, arg.name, arg.type);
|
|
91
|
+
arg.tags.forEach(tag => argState.tags.add(tag));
|
|
92
|
+
if (arg.type.endsWith('!')) {
|
|
93
|
+
argState.type = arg.type;
|
|
94
|
+
}
|
|
95
|
+
if (arg.inaccessible) {
|
|
96
|
+
argState.inaccessible = true;
|
|
97
|
+
}
|
|
98
|
+
if (!field.external) {
|
|
99
|
+
argState.description = arg.description;
|
|
100
|
+
}
|
|
101
|
+
if (arg.deprecated && !argState.deprecated) {
|
|
102
|
+
argState.deprecated = arg.deprecated;
|
|
103
|
+
}
|
|
104
|
+
arg.ast.directives.forEach(directive => {
|
|
105
|
+
argState.ast.directives.push(directive);
|
|
106
|
+
});
|
|
107
|
+
if (typeof arg.defaultValue === 'string') {
|
|
108
|
+
argState.defaultValue = arg.defaultValue;
|
|
109
|
+
}
|
|
110
|
+
argState.byGraph.set(graph.id, {
|
|
111
|
+
type: arg.type,
|
|
112
|
+
inaccessible: arg.inaccessible,
|
|
113
|
+
defaultValue: arg.defaultValue,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
composeSupergraphNode(objectType, graphs) {
|
|
119
|
+
const isQuery = objectType.name === 'Query';
|
|
120
|
+
return createObjectTypeNode({
|
|
121
|
+
name: objectType.name,
|
|
122
|
+
ast: {
|
|
123
|
+
directives: convertToConst(objectType.ast.directives),
|
|
124
|
+
},
|
|
125
|
+
description: objectType.description,
|
|
126
|
+
fields: Array.from(objectType.fields.values()).map(field => {
|
|
127
|
+
const fieldInGraphs = Array.from(field.byGraph.entries());
|
|
128
|
+
const hasDifferentOutputType = fieldInGraphs.some(([_, meta]) => meta.type !== field.type);
|
|
129
|
+
const isDefinedEverywhere = field.byGraph.size === (isQuery ? graphs.size : objectType.byGraph.size);
|
|
130
|
+
let joinFields = [];
|
|
131
|
+
const differencesBetweenGraphs = {
|
|
132
|
+
override: false,
|
|
133
|
+
type: false,
|
|
134
|
+
external: false,
|
|
135
|
+
provides: false,
|
|
136
|
+
requires: false,
|
|
137
|
+
};
|
|
138
|
+
for (const [graphId, meta] of fieldInGraphs) {
|
|
139
|
+
if (meta.external) {
|
|
140
|
+
differencesBetweenGraphs.external = field.usedAsKey
|
|
141
|
+
? objectType.byGraph.get(graphId).extension !== true
|
|
142
|
+
: true;
|
|
143
|
+
}
|
|
144
|
+
if (meta.override !== null) {
|
|
145
|
+
differencesBetweenGraphs.override = true;
|
|
146
|
+
}
|
|
147
|
+
if (meta.provides !== null) {
|
|
148
|
+
differencesBetweenGraphs.provides = true;
|
|
149
|
+
}
|
|
150
|
+
if (meta.requires !== null) {
|
|
151
|
+
differencesBetweenGraphs.requires = true;
|
|
152
|
+
}
|
|
153
|
+
if (meta.type !== field.type) {
|
|
154
|
+
differencesBetweenGraphs.type = true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (isQuery) {
|
|
158
|
+
if (differencesBetweenGraphs.override) {
|
|
159
|
+
const graphsWithOverride = fieldInGraphs.filter(([_, meta]) => meta.override !== null);
|
|
160
|
+
joinFields = graphsWithOverride.map(([graphId, meta]) => ({
|
|
161
|
+
graph: graphId,
|
|
162
|
+
override: meta.override ?? undefined,
|
|
163
|
+
type: differencesBetweenGraphs.type ? meta.type : undefined,
|
|
164
|
+
external: meta.external ?? undefined,
|
|
165
|
+
provides: meta.provides ?? undefined,
|
|
166
|
+
requires: meta.requires ?? undefined,
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
joinFields =
|
|
171
|
+
graphs.size > 1 && !isDefinedEverywhere
|
|
172
|
+
? fieldInGraphs.map(([graphId, meta]) => ({
|
|
173
|
+
graph: graphId,
|
|
174
|
+
provides: differencesBetweenGraphs.provides
|
|
175
|
+
? meta.provides ?? undefined
|
|
176
|
+
: undefined,
|
|
177
|
+
}))
|
|
178
|
+
: [];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else if (isDefinedEverywhere) {
|
|
182
|
+
const hasDifferencesBetweenGraphs = Object.values(differencesBetweenGraphs).some(value => value === true);
|
|
183
|
+
if (differencesBetweenGraphs.override) {
|
|
184
|
+
const graphsWithOverride = fieldInGraphs.filter(([_, meta]) => meta.override !== null);
|
|
185
|
+
joinFields = graphsWithOverride.map(([graphId, meta]) => ({
|
|
186
|
+
graph: graphId,
|
|
187
|
+
override: meta.override ?? undefined,
|
|
188
|
+
type: differencesBetweenGraphs.type ? meta.type : undefined,
|
|
189
|
+
external: meta.external ?? undefined,
|
|
190
|
+
provides: meta.provides ?? undefined,
|
|
191
|
+
requires: meta.requires ?? undefined,
|
|
192
|
+
}));
|
|
193
|
+
}
|
|
194
|
+
else if (hasDifferencesBetweenGraphs) {
|
|
195
|
+
joinFields = fieldInGraphs.map(([graphId, meta]) => ({
|
|
196
|
+
graph: graphId,
|
|
197
|
+
type: differencesBetweenGraphs.type ? meta.type : undefined,
|
|
198
|
+
override: meta.override ?? undefined,
|
|
199
|
+
external: meta.external
|
|
200
|
+
?
|
|
201
|
+
field.usedAsKey && objectType.byGraph.get(graphId).extension === true
|
|
202
|
+
? false
|
|
203
|
+
: true
|
|
204
|
+
: undefined,
|
|
205
|
+
provides: meta.provides ?? undefined,
|
|
206
|
+
requires: meta.requires ?? undefined,
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
if (differencesBetweenGraphs.override) {
|
|
212
|
+
const graphsWithOverride = fieldInGraphs.filter(([_, meta]) => meta.override !== null);
|
|
213
|
+
joinFields = graphsWithOverride.map(([graphId, meta]) => ({
|
|
214
|
+
graph: graphId,
|
|
215
|
+
override: meta.override ?? undefined,
|
|
216
|
+
type: differencesBetweenGraphs.type ? meta.type : undefined,
|
|
217
|
+
external: meta.external ?? undefined,
|
|
218
|
+
provides: meta.provides ?? undefined,
|
|
219
|
+
requires: meta.requires ?? undefined,
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
joinFields = fieldInGraphs.map(([graphId, meta]) => ({
|
|
224
|
+
graph: graphId,
|
|
225
|
+
type: hasDifferentOutputType ? meta.type : undefined,
|
|
226
|
+
override: meta.override ?? undefined,
|
|
227
|
+
external: meta.external ?? undefined,
|
|
228
|
+
provides: meta.provides ?? undefined,
|
|
229
|
+
requires: meta.requires ?? undefined,
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
name: field.name,
|
|
235
|
+
type: field.type,
|
|
236
|
+
inaccessible: field.inaccessible,
|
|
237
|
+
tags: Array.from(field.tags),
|
|
238
|
+
description: field.description,
|
|
239
|
+
deprecated: field.deprecated,
|
|
240
|
+
ast: {
|
|
241
|
+
directives: convertToConst(field.ast.directives),
|
|
242
|
+
},
|
|
243
|
+
join: {
|
|
244
|
+
field: joinFields,
|
|
245
|
+
},
|
|
246
|
+
arguments: Array.from(field.args.values())
|
|
247
|
+
.filter(arg => {
|
|
248
|
+
if (arg.byGraph.size !== field.byGraph.size) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
return true;
|
|
252
|
+
})
|
|
253
|
+
.map(arg => {
|
|
254
|
+
return {
|
|
255
|
+
name: arg.name,
|
|
256
|
+
type: arg.type,
|
|
257
|
+
inaccessible: arg.inaccessible,
|
|
258
|
+
tags: Array.from(arg.tags),
|
|
259
|
+
defaultValue: arg.defaultValue,
|
|
260
|
+
description: arg.description,
|
|
261
|
+
deprecated: arg.deprecated,
|
|
262
|
+
ast: {
|
|
263
|
+
directives: convertToConst(arg.ast.directives),
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
}),
|
|
267
|
+
};
|
|
268
|
+
}),
|
|
269
|
+
interfaces: Array.from(objectType.interfaces),
|
|
270
|
+
tags: Array.from(objectType.tags),
|
|
271
|
+
inaccessible: objectType.inaccessible,
|
|
272
|
+
join: {
|
|
273
|
+
type: isQuery
|
|
274
|
+
?
|
|
275
|
+
Array.from(graphs.values()).map(graph => ({
|
|
276
|
+
graph: graph.id,
|
|
277
|
+
}))
|
|
278
|
+
:
|
|
279
|
+
Array.from(objectType.byGraph.entries())
|
|
280
|
+
.map(([graphId, meta]) => {
|
|
281
|
+
if (meta.keys.length) {
|
|
282
|
+
return meta.keys.map(key => ({
|
|
283
|
+
graph: graphId,
|
|
284
|
+
key: key.fields,
|
|
285
|
+
extension: isRealExtension(meta, graphs.get(graphId).version),
|
|
286
|
+
resolvable: key.resolvable,
|
|
287
|
+
}));
|
|
288
|
+
}
|
|
289
|
+
return [
|
|
290
|
+
{
|
|
291
|
+
graph: graphId,
|
|
292
|
+
},
|
|
293
|
+
];
|
|
294
|
+
})
|
|
295
|
+
.flat(1),
|
|
296
|
+
implements: objectType.interfaces.size > 0
|
|
297
|
+
? Array.from(objectType.byGraph.entries())
|
|
298
|
+
.map(([graph, meta]) => {
|
|
299
|
+
if (meta.interfaces.size > 0) {
|
|
300
|
+
return Array.from(meta.interfaces).map(interfaceName => ({
|
|
301
|
+
graph: graph.toUpperCase(),
|
|
302
|
+
interface: interfaceName,
|
|
303
|
+
}));
|
|
304
|
+
}
|
|
305
|
+
return [];
|
|
306
|
+
})
|
|
307
|
+
.flat(1)
|
|
308
|
+
: [],
|
|
309
|
+
},
|
|
310
|
+
});
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function getOrCreateObjectType(state, typeName) {
|
|
315
|
+
const existing = state.get(typeName);
|
|
316
|
+
if (existing) {
|
|
317
|
+
return existing;
|
|
318
|
+
}
|
|
319
|
+
const def = {
|
|
320
|
+
name: typeName,
|
|
321
|
+
tags: new Set(),
|
|
322
|
+
hasDefinition: false,
|
|
323
|
+
inaccessible: false,
|
|
324
|
+
interfaces: new Set(),
|
|
325
|
+
byGraph: new Map(),
|
|
326
|
+
fields: new Map(),
|
|
327
|
+
ast: {
|
|
328
|
+
directives: [],
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
state.set(typeName, def);
|
|
332
|
+
return def;
|
|
333
|
+
}
|
|
334
|
+
function getOrCreateField(objectTypeState, fieldName, fieldType) {
|
|
335
|
+
const existing = objectTypeState.fields.get(fieldName);
|
|
336
|
+
if (existing) {
|
|
337
|
+
return existing;
|
|
338
|
+
}
|
|
339
|
+
const def = {
|
|
340
|
+
name: fieldName,
|
|
341
|
+
type: fieldType,
|
|
342
|
+
tags: new Set(),
|
|
343
|
+
inaccessible: false,
|
|
344
|
+
usedAsKey: false,
|
|
345
|
+
override: null,
|
|
346
|
+
byGraph: new Map(),
|
|
347
|
+
args: new Map(),
|
|
348
|
+
ast: {
|
|
349
|
+
directives: [],
|
|
350
|
+
},
|
|
351
|
+
internal: {
|
|
352
|
+
seenNonExternal: false,
|
|
353
|
+
},
|
|
354
|
+
};
|
|
355
|
+
objectTypeState.fields.set(fieldName, def);
|
|
356
|
+
return def;
|
|
357
|
+
}
|
|
358
|
+
function getOrCreateArg(fieldState, argName, argType) {
|
|
359
|
+
const existing = fieldState.args.get(argName);
|
|
360
|
+
if (existing) {
|
|
361
|
+
return existing;
|
|
362
|
+
}
|
|
363
|
+
const def = {
|
|
364
|
+
name: argName,
|
|
365
|
+
type: argType,
|
|
366
|
+
tags: new Set(),
|
|
367
|
+
inaccessible: false,
|
|
368
|
+
byGraph: new Map(),
|
|
369
|
+
ast: {
|
|
370
|
+
directives: [],
|
|
371
|
+
},
|
|
372
|
+
};
|
|
373
|
+
fieldState.args.set(argName, def);
|
|
374
|
+
return def;
|
|
375
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createScalarTypeNode } from './ast.js';
|
|
2
|
+
import { convertToConst } from './common.js';
|
|
3
|
+
export function scalarTypeBuilder() {
|
|
4
|
+
return {
|
|
5
|
+
visitSubgraphState(graph, state, typeName, type) {
|
|
6
|
+
const scalarTypeState = getOrCreateScalarType(state, typeName);
|
|
7
|
+
type.tags.forEach(tag => scalarTypeState.tags.add(tag));
|
|
8
|
+
if (type.inaccessible) {
|
|
9
|
+
scalarTypeState.inaccessible = true;
|
|
10
|
+
}
|
|
11
|
+
if (type.description && !scalarTypeState.description) {
|
|
12
|
+
scalarTypeState.description = type.description;
|
|
13
|
+
}
|
|
14
|
+
if (type.specifiedBy && !scalarTypeState.specifiedBy) {
|
|
15
|
+
scalarTypeState.specifiedBy = type.specifiedBy;
|
|
16
|
+
}
|
|
17
|
+
type.ast.directives.forEach(directive => {
|
|
18
|
+
scalarTypeState.ast.directives.push(directive);
|
|
19
|
+
});
|
|
20
|
+
scalarTypeState.byGraph.set(graph.id, {
|
|
21
|
+
inaccessible: type.inaccessible,
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
composeSupergraphNode(scalarType) {
|
|
25
|
+
return createScalarTypeNode({
|
|
26
|
+
name: scalarType.name,
|
|
27
|
+
tags: Array.from(scalarType.tags),
|
|
28
|
+
inaccessible: scalarType.inaccessible,
|
|
29
|
+
description: scalarType.description,
|
|
30
|
+
specifiedBy: scalarType.specifiedBy,
|
|
31
|
+
join: {
|
|
32
|
+
type: Array.from(scalarType.byGraph.keys()).map(graphName => ({
|
|
33
|
+
graph: graphName.toUpperCase(),
|
|
34
|
+
})),
|
|
35
|
+
},
|
|
36
|
+
ast: {
|
|
37
|
+
directives: convertToConst(scalarType.ast.directives),
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function getOrCreateScalarType(state, typeName) {
|
|
44
|
+
const existing = state.get(typeName);
|
|
45
|
+
if (existing) {
|
|
46
|
+
return existing;
|
|
47
|
+
}
|
|
48
|
+
const def = {
|
|
49
|
+
name: typeName,
|
|
50
|
+
tags: new Set(),
|
|
51
|
+
inaccessible: false,
|
|
52
|
+
byGraph: new Map(),
|
|
53
|
+
ast: {
|
|
54
|
+
directives: [],
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
state.set(typeName, def);
|
|
58
|
+
return def;
|
|
59
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createUnionTypeNode } from './ast.js';
|
|
2
|
+
export function unionTypeBuilder() {
|
|
3
|
+
return {
|
|
4
|
+
visitSubgraphState(graph, state, typeName, type) {
|
|
5
|
+
const unionTypeState = getOrCreateUnionType(state, typeName);
|
|
6
|
+
type.tags.forEach(tag => unionTypeState.tags.add(tag));
|
|
7
|
+
if (type.inaccessible) {
|
|
8
|
+
unionTypeState.inaccessible = true;
|
|
9
|
+
}
|
|
10
|
+
if (type.isDefinition) {
|
|
11
|
+
unionTypeState.hasDefinition = true;
|
|
12
|
+
}
|
|
13
|
+
if (type.description && !unionTypeState.description) {
|
|
14
|
+
unionTypeState.description = type.description;
|
|
15
|
+
}
|
|
16
|
+
unionTypeState.byGraph.set(graph.id, {
|
|
17
|
+
members: type.members,
|
|
18
|
+
});
|
|
19
|
+
for (const member of type.members) {
|
|
20
|
+
unionTypeState.members.add(member);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
composeSupergraphNode(unionType) {
|
|
24
|
+
return createUnionTypeNode({
|
|
25
|
+
name: unionType.name,
|
|
26
|
+
members: Array.from(unionType.members),
|
|
27
|
+
tags: Array.from(unionType.tags),
|
|
28
|
+
inaccessible: unionType.inaccessible,
|
|
29
|
+
description: unionType.description,
|
|
30
|
+
join: {
|
|
31
|
+
type: Array.from(unionType.byGraph.keys()).map(graphName => ({
|
|
32
|
+
graph: graphName.toUpperCase(),
|
|
33
|
+
})),
|
|
34
|
+
unionMember: Array.from(unionType.byGraph.entries())
|
|
35
|
+
.map(([graphName, meta]) => {
|
|
36
|
+
const graph = graphName.toUpperCase();
|
|
37
|
+
return Array.from(meta.members).map(member => ({ graph, member }));
|
|
38
|
+
})
|
|
39
|
+
.flat(1),
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function getOrCreateUnionType(state, typeName) {
|
|
46
|
+
const existing = state.get(typeName);
|
|
47
|
+
if (existing) {
|
|
48
|
+
return existing;
|
|
49
|
+
}
|
|
50
|
+
const def = {
|
|
51
|
+
name: typeName,
|
|
52
|
+
members: new Set(),
|
|
53
|
+
tags: new Set(),
|
|
54
|
+
inaccessible: false,
|
|
55
|
+
hasDefinition: false,
|
|
56
|
+
byGraph: new Map(),
|
|
57
|
+
};
|
|
58
|
+
state.set(typeName, def);
|
|
59
|
+
return def;
|
|
60
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export function visitSupergraphState(supergraphState, visitors) {
|
|
2
|
+
supergraphState.objectTypes.forEach(objectTypeState => {
|
|
3
|
+
for (const visitor of visitors) {
|
|
4
|
+
if (visitor.ObjectType) {
|
|
5
|
+
visitor.ObjectType(objectTypeState);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
for (const fieldState of objectTypeState.fields.values()) {
|
|
9
|
+
for (const visitor of visitors) {
|
|
10
|
+
if (visitor.ObjectTypeField) {
|
|
11
|
+
visitor.ObjectTypeField(objectTypeState, fieldState);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
for (const argState of fieldState.args.values()) {
|
|
15
|
+
for (const visitor of visitors) {
|
|
16
|
+
if (visitor.ObjectTypeFieldArg) {
|
|
17
|
+
visitor.ObjectTypeFieldArg(objectTypeState, fieldState, argState);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
supergraphState.enumTypes.forEach(enumTypeState => {
|
|
24
|
+
for (const visitor of visitors) {
|
|
25
|
+
if (visitor.EnumType) {
|
|
26
|
+
visitor.EnumType(enumTypeState);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
supergraphState.inputObjectTypes.forEach(inputObjectTypeState => {
|
|
31
|
+
for (const visitor of visitors) {
|
|
32
|
+
if (visitor.InputObjectType) {
|
|
33
|
+
visitor.InputObjectType(inputObjectTypeState);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
for (const fieldState of inputObjectTypeState.fields.values()) {
|
|
37
|
+
for (const visitor of visitors) {
|
|
38
|
+
if (visitor.InputObjectTypeField) {
|
|
39
|
+
visitor.InputObjectTypeField(inputObjectTypeState, fieldState);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
supergraphState.interfaceTypes.forEach(interfaceTypeState => {
|
|
45
|
+
for (const visitor of visitors) {
|
|
46
|
+
if (visitor.InterfaceType) {
|
|
47
|
+
visitor.InterfaceType(interfaceTypeState);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
supergraphState.directives.forEach(directiveState => {
|
|
52
|
+
for (const visitor of visitors) {
|
|
53
|
+
if (visitor.Directive) {
|
|
54
|
+
visitor.Directive(directiveState);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|