@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,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.directiveBuilder = void 0;
|
|
4
|
+
const ast_js_1 = require("./ast.js");
|
|
5
|
+
const common_js_1 = require("./common.js");
|
|
6
|
+
function directiveBuilder() {
|
|
7
|
+
return {
|
|
8
|
+
visitSubgraphState(graph, state, directiveName, directive) {
|
|
9
|
+
if (!directive.composed) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const directiveState = getOrCreateDirective(state, directiveName);
|
|
13
|
+
for (const location of directive.locations) {
|
|
14
|
+
directiveState.locations.add(location);
|
|
15
|
+
}
|
|
16
|
+
if (directive.repeatable) {
|
|
17
|
+
directiveState.repeatable = true;
|
|
18
|
+
}
|
|
19
|
+
for (const arg of directive.args.values()) {
|
|
20
|
+
const argState = getOrCreateArg(directiveState, arg.name, arg.type);
|
|
21
|
+
arg.tags.forEach(tag => argState.tags.add(tag));
|
|
22
|
+
if (arg.type.endsWith('!')) {
|
|
23
|
+
argState.type = arg.type;
|
|
24
|
+
}
|
|
25
|
+
arg.ast.directives.forEach(directive => {
|
|
26
|
+
argState.ast.directives.push(directive);
|
|
27
|
+
});
|
|
28
|
+
if (arg.inaccessible) {
|
|
29
|
+
argState.inaccessible = true;
|
|
30
|
+
}
|
|
31
|
+
argState.byGraph.set(graph.id, {
|
|
32
|
+
type: arg.type,
|
|
33
|
+
defaultValue: arg.defaultValue,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
directiveState.byGraph.set(graph.id, {
|
|
37
|
+
locations: directive.locations,
|
|
38
|
+
repeatable: directive.repeatable,
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
composeSupergraphNode(directive) {
|
|
42
|
+
return (0, ast_js_1.createDirectiveNode)({
|
|
43
|
+
name: directive.name,
|
|
44
|
+
locations: Array.from(directive.locations),
|
|
45
|
+
repeatable: directive.repeatable,
|
|
46
|
+
arguments: Array.from(directive.args.values()).map(arg => ({
|
|
47
|
+
name: arg.name,
|
|
48
|
+
type: arg.type,
|
|
49
|
+
tags: Array.from(arg.tags),
|
|
50
|
+
inaccessible: arg.inaccessible,
|
|
51
|
+
defaultValue: arg.defaultValue,
|
|
52
|
+
ast: {
|
|
53
|
+
directives: (0, common_js_1.convertToConst)(arg.ast.directives),
|
|
54
|
+
},
|
|
55
|
+
})),
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
exports.directiveBuilder = directiveBuilder;
|
|
61
|
+
function getOrCreateDirective(state, directiveName) {
|
|
62
|
+
const existing = state.get(directiveName);
|
|
63
|
+
if (existing) {
|
|
64
|
+
return existing;
|
|
65
|
+
}
|
|
66
|
+
const def = {
|
|
67
|
+
name: directiveName,
|
|
68
|
+
locations: new Set(),
|
|
69
|
+
byGraph: new Map(),
|
|
70
|
+
args: new Map(),
|
|
71
|
+
repeatable: false,
|
|
72
|
+
};
|
|
73
|
+
state.set(directiveName, def);
|
|
74
|
+
return def;
|
|
75
|
+
}
|
|
76
|
+
function getOrCreateArg(directiveState, argName, argType) {
|
|
77
|
+
const existing = directiveState.args.get(argName);
|
|
78
|
+
if (existing) {
|
|
79
|
+
return existing;
|
|
80
|
+
}
|
|
81
|
+
const def = {
|
|
82
|
+
name: argName,
|
|
83
|
+
type: argType,
|
|
84
|
+
inaccessible: false,
|
|
85
|
+
tags: new Set(),
|
|
86
|
+
byGraph: new Map(),
|
|
87
|
+
ast: {
|
|
88
|
+
directives: [],
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
directiveState.args.set(argName, def);
|
|
92
|
+
return def;
|
|
93
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enumTypeBuilder = void 0;
|
|
4
|
+
const ast_js_1 = require("./ast.js");
|
|
5
|
+
function enumTypeBuilder() {
|
|
6
|
+
return {
|
|
7
|
+
visitSubgraphState(graph, state, typeName, type) {
|
|
8
|
+
const enumTypeState = getOrCreateEnumType(state, typeName);
|
|
9
|
+
type.tags.forEach(tag => enumTypeState.tags.add(tag));
|
|
10
|
+
if (type.inaccessible) {
|
|
11
|
+
enumTypeState.inaccessible = true;
|
|
12
|
+
}
|
|
13
|
+
if (type.isDefinition) {
|
|
14
|
+
enumTypeState.hasDefinition = true;
|
|
15
|
+
}
|
|
16
|
+
if (type.description && !enumTypeState.description) {
|
|
17
|
+
enumTypeState.description = type.description;
|
|
18
|
+
}
|
|
19
|
+
if (type.referencedByInputType) {
|
|
20
|
+
enumTypeState.referencedByInputType = true;
|
|
21
|
+
type.inputTypeReferences.forEach(ref => {
|
|
22
|
+
enumTypeState.inputTypeReferences.add(ref);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (type.referencedByOutputType) {
|
|
26
|
+
enumTypeState.referencedByOutputType = true;
|
|
27
|
+
type.outputTypeReferences.forEach(ref => {
|
|
28
|
+
enumTypeState.outputTypeReferences.add(ref);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
enumTypeState.byGraph.set(graph.id, {
|
|
32
|
+
inaccessible: type.inaccessible,
|
|
33
|
+
});
|
|
34
|
+
for (const value of type.values.values()) {
|
|
35
|
+
const valueState = getOrCreateEnumValue(enumTypeState, value.name);
|
|
36
|
+
value.tags.forEach(tag => valueState.tags.add(tag));
|
|
37
|
+
if (value.inaccessible) {
|
|
38
|
+
valueState.inaccessible = true;
|
|
39
|
+
}
|
|
40
|
+
if (value.deprecated && !valueState.deprecated) {
|
|
41
|
+
valueState.deprecated = value.deprecated;
|
|
42
|
+
}
|
|
43
|
+
if (value.description && !valueState.description) {
|
|
44
|
+
valueState.description = value.description;
|
|
45
|
+
}
|
|
46
|
+
valueState.byGraph.set(graph.id, {
|
|
47
|
+
inaccessible: value.inaccessible,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
composeSupergraphNode(enumType) {
|
|
52
|
+
const mergeMethod = decideOnEnumMergeStrategy(enumType.referencedByInputType, enumType.referencedByOutputType);
|
|
53
|
+
const values = mergeMethod === 'intersection'
|
|
54
|
+
? intersectionOfEnumValues(enumType)
|
|
55
|
+
: Array.from(enumType.values);
|
|
56
|
+
return (0, ast_js_1.createEnumTypeNode)({
|
|
57
|
+
name: enumType.name,
|
|
58
|
+
values: values.map(([_, value]) => ({
|
|
59
|
+
name: value.name,
|
|
60
|
+
join: {
|
|
61
|
+
enumValue: Array.from(value.byGraph.keys()).map(graph => ({
|
|
62
|
+
graph: graph.toUpperCase(),
|
|
63
|
+
})),
|
|
64
|
+
},
|
|
65
|
+
tags: Array.from(value.tags),
|
|
66
|
+
inaccessible: value.inaccessible,
|
|
67
|
+
description: value.description,
|
|
68
|
+
deprecated: value.deprecated,
|
|
69
|
+
})),
|
|
70
|
+
tags: Array.from(enumType.tags),
|
|
71
|
+
inaccessible: enumType.inaccessible,
|
|
72
|
+
description: enumType.description,
|
|
73
|
+
join: {
|
|
74
|
+
type: Array.from(enumType.byGraph.keys()).map(graphName => ({
|
|
75
|
+
graph: graphName.toUpperCase(),
|
|
76
|
+
})),
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
exports.enumTypeBuilder = enumTypeBuilder;
|
|
83
|
+
function decideOnEnumMergeStrategy(referencedByInputType, referencedByOutputType) {
|
|
84
|
+
if (referencedByInputType === referencedByOutputType) {
|
|
85
|
+
return 'equal';
|
|
86
|
+
}
|
|
87
|
+
if (referencedByInputType) {
|
|
88
|
+
return 'intersection';
|
|
89
|
+
}
|
|
90
|
+
if (referencedByOutputType) {
|
|
91
|
+
return 'union';
|
|
92
|
+
}
|
|
93
|
+
return 'equal';
|
|
94
|
+
}
|
|
95
|
+
function intersectionOfEnumValues(enumType) {
|
|
96
|
+
const numberOfGraphs = enumType.byGraph.size;
|
|
97
|
+
return Array.from(enumType.values).filter(([_, value]) => value.byGraph.size === numberOfGraphs);
|
|
98
|
+
}
|
|
99
|
+
function getOrCreateEnumType(state, typeName) {
|
|
100
|
+
const existing = state.get(typeName);
|
|
101
|
+
if (existing) {
|
|
102
|
+
return existing;
|
|
103
|
+
}
|
|
104
|
+
const def = {
|
|
105
|
+
name: typeName,
|
|
106
|
+
values: new Map(),
|
|
107
|
+
tags: new Set(),
|
|
108
|
+
hasDefinition: false,
|
|
109
|
+
inaccessible: false,
|
|
110
|
+
referencedByInputType: false,
|
|
111
|
+
referencedByOutputType: false,
|
|
112
|
+
inputTypeReferences: new Set(),
|
|
113
|
+
outputTypeReferences: new Set(),
|
|
114
|
+
byGraph: new Map(),
|
|
115
|
+
};
|
|
116
|
+
state.set(typeName, def);
|
|
117
|
+
return def;
|
|
118
|
+
}
|
|
119
|
+
function getOrCreateEnumValue(enumTypeState, enumValueName) {
|
|
120
|
+
const existing = enumTypeState.values.get(enumValueName);
|
|
121
|
+
if (existing) {
|
|
122
|
+
return existing;
|
|
123
|
+
}
|
|
124
|
+
const def = {
|
|
125
|
+
name: enumValueName,
|
|
126
|
+
tags: new Set(),
|
|
127
|
+
inaccessible: false,
|
|
128
|
+
byGraph: new Map(),
|
|
129
|
+
};
|
|
130
|
+
enumTypeState.values.set(enumValueName, def);
|
|
131
|
+
return def;
|
|
132
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inputObjectTypeBuilder = void 0;
|
|
4
|
+
const ast_js_1 = require("./ast.js");
|
|
5
|
+
function inputObjectTypeBuilder() {
|
|
6
|
+
return {
|
|
7
|
+
visitSubgraphState(graph, state, typeName, type) {
|
|
8
|
+
const inputObjectTypeState = getOrCreateInputObjectType(state, typeName);
|
|
9
|
+
type.tags.forEach(tag => inputObjectTypeState.tags.add(tag));
|
|
10
|
+
if (type.inaccessible) {
|
|
11
|
+
inputObjectTypeState.inaccessible = true;
|
|
12
|
+
}
|
|
13
|
+
const isDefinition = type.isDefinition && !type.extension;
|
|
14
|
+
if (type.description && !inputObjectTypeState.description) {
|
|
15
|
+
inputObjectTypeState.description = type.description;
|
|
16
|
+
}
|
|
17
|
+
if (type.isDefinition) {
|
|
18
|
+
inputObjectTypeState.hasDefinition = true;
|
|
19
|
+
}
|
|
20
|
+
inputObjectTypeState.byGraph.set(graph.id, {
|
|
21
|
+
inaccessible: type.inaccessible,
|
|
22
|
+
});
|
|
23
|
+
for (const field of type.fields.values()) {
|
|
24
|
+
const fieldState = getOrCreateField(inputObjectTypeState, field.name, field.type);
|
|
25
|
+
field.tags.forEach(tag => fieldState.tags.add(tag));
|
|
26
|
+
if (field.type.endsWith('!') && !fieldState.type.endsWith('!')) {
|
|
27
|
+
fieldState.type = field.type;
|
|
28
|
+
}
|
|
29
|
+
if (field.inaccessible) {
|
|
30
|
+
fieldState.inaccessible = true;
|
|
31
|
+
}
|
|
32
|
+
if (field.description && !fieldState.description) {
|
|
33
|
+
fieldState.description = field.description;
|
|
34
|
+
}
|
|
35
|
+
if (field.deprecated && !fieldState.deprecated) {
|
|
36
|
+
fieldState.deprecated = field.deprecated;
|
|
37
|
+
}
|
|
38
|
+
if (typeof field.defaultValue === 'string') {
|
|
39
|
+
fieldState.defaultValue = field.defaultValue;
|
|
40
|
+
}
|
|
41
|
+
fieldState.byGraph.set(graph.id, {
|
|
42
|
+
type: field.type,
|
|
43
|
+
inaccessible: field.inaccessible,
|
|
44
|
+
defaultValue: field.defaultValue,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
composeSupergraphNode(inputObjectType) {
|
|
49
|
+
return (0, ast_js_1.createInputObjectTypeNode)({
|
|
50
|
+
name: inputObjectType.name,
|
|
51
|
+
tags: Array.from(inputObjectType.tags),
|
|
52
|
+
inaccessible: inputObjectType.inaccessible,
|
|
53
|
+
description: inputObjectType.description,
|
|
54
|
+
fields: Array.from(inputObjectType.fields.values())
|
|
55
|
+
.filter(field => {
|
|
56
|
+
if (field.byGraph.size !== inputObjectType.byGraph.size) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
})
|
|
61
|
+
.map(field => {
|
|
62
|
+
const hasDifferentType = Array.from(field.byGraph.values()).some(f => f.type !== field.type);
|
|
63
|
+
return {
|
|
64
|
+
name: field.name,
|
|
65
|
+
type: field.type,
|
|
66
|
+
tags: Array.from(field.tags),
|
|
67
|
+
inaccessible: field.inaccessible,
|
|
68
|
+
defaultValue: field.defaultValue,
|
|
69
|
+
description: field.description,
|
|
70
|
+
deprecated: field.deprecated,
|
|
71
|
+
join: {
|
|
72
|
+
field: hasDifferentType
|
|
73
|
+
? Array.from(field.byGraph).map(([graph, fieldByGraph]) => ({
|
|
74
|
+
graph,
|
|
75
|
+
type: fieldByGraph.type,
|
|
76
|
+
}))
|
|
77
|
+
: [],
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}),
|
|
81
|
+
join: {
|
|
82
|
+
type: Array.from(inputObjectType.byGraph.keys()).map(graph => ({ graph })),
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
exports.inputObjectTypeBuilder = inputObjectTypeBuilder;
|
|
89
|
+
function getOrCreateInputObjectType(state, typeName) {
|
|
90
|
+
const existing = state.get(typeName);
|
|
91
|
+
if (existing) {
|
|
92
|
+
return existing;
|
|
93
|
+
}
|
|
94
|
+
const def = {
|
|
95
|
+
name: typeName,
|
|
96
|
+
tags: new Set(),
|
|
97
|
+
hasDefinition: false,
|
|
98
|
+
inaccessible: false,
|
|
99
|
+
byGraph: new Map(),
|
|
100
|
+
fields: new Map(),
|
|
101
|
+
};
|
|
102
|
+
state.set(typeName, def);
|
|
103
|
+
return def;
|
|
104
|
+
}
|
|
105
|
+
function getOrCreateField(objectTypeState, fieldName, fieldType) {
|
|
106
|
+
const existing = objectTypeState.fields.get(fieldName);
|
|
107
|
+
if (existing) {
|
|
108
|
+
return existing;
|
|
109
|
+
}
|
|
110
|
+
const def = {
|
|
111
|
+
name: fieldName,
|
|
112
|
+
type: fieldType,
|
|
113
|
+
tags: new Set(),
|
|
114
|
+
inaccessible: false,
|
|
115
|
+
byGraph: new Map(),
|
|
116
|
+
};
|
|
117
|
+
objectTypeState.fields.set(fieldName, def);
|
|
118
|
+
return def;
|
|
119
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.interfaceTypeBuilder = void 0;
|
|
4
|
+
const ast_js_1 = require("./ast.js");
|
|
5
|
+
const common_js_1 = require("./common.js");
|
|
6
|
+
function interfaceTypeBuilder() {
|
|
7
|
+
return {
|
|
8
|
+
visitSubgraphState(graph, state, typeName, type) {
|
|
9
|
+
const interfaceTypeState = getOrCreateInterfaceType(state, typeName);
|
|
10
|
+
type.tags.forEach(tag => interfaceTypeState.tags.add(tag));
|
|
11
|
+
if (type.inaccessible) {
|
|
12
|
+
interfaceTypeState.inaccessible = true;
|
|
13
|
+
}
|
|
14
|
+
if (type.isDefinition) {
|
|
15
|
+
interfaceTypeState.hasDefinition = true;
|
|
16
|
+
}
|
|
17
|
+
if (type.description && !interfaceTypeState.description) {
|
|
18
|
+
interfaceTypeState.description = type.description;
|
|
19
|
+
}
|
|
20
|
+
type.ast.directives.forEach(directive => {
|
|
21
|
+
interfaceTypeState.ast.directives.push(directive);
|
|
22
|
+
});
|
|
23
|
+
type.interfaces.forEach(interfaceName => interfaceTypeState.interfaces.add(interfaceName));
|
|
24
|
+
type.implementedBy.forEach(objectTypeName => interfaceTypeState.implementedBy.add(objectTypeName));
|
|
25
|
+
interfaceTypeState.byGraph.set(graph.id, {
|
|
26
|
+
extension: type.extension,
|
|
27
|
+
keys: type.keys,
|
|
28
|
+
interfaces: type.interfaces,
|
|
29
|
+
implementedBy: type.implementedBy,
|
|
30
|
+
});
|
|
31
|
+
for (const field of type.fields.values()) {
|
|
32
|
+
const fieldState = getOrCreateInterfaceField(interfaceTypeState, field.name, field.type);
|
|
33
|
+
field.tags.forEach(tag => fieldState.tags.add(tag));
|
|
34
|
+
if (!field.type.endsWith('!') && fieldState.type.endsWith('!')) {
|
|
35
|
+
fieldState.type = field.type;
|
|
36
|
+
}
|
|
37
|
+
if (field.inaccessible) {
|
|
38
|
+
fieldState.inaccessible = true;
|
|
39
|
+
}
|
|
40
|
+
if (field.deprecated && !fieldState.deprecated) {
|
|
41
|
+
fieldState.deprecated = field.deprecated;
|
|
42
|
+
}
|
|
43
|
+
if (field.description && !fieldState.description) {
|
|
44
|
+
fieldState.description = field.description;
|
|
45
|
+
}
|
|
46
|
+
field.ast.directives.forEach(directive => {
|
|
47
|
+
fieldState.ast.directives.push(directive);
|
|
48
|
+
});
|
|
49
|
+
fieldState.byGraph.set(graph.id, {
|
|
50
|
+
type: field.type,
|
|
51
|
+
override: field.override,
|
|
52
|
+
provides: field.provides,
|
|
53
|
+
requires: field.requires,
|
|
54
|
+
});
|
|
55
|
+
for (const arg of field.args.values()) {
|
|
56
|
+
const argState = getOrCreateArg(fieldState, arg.name, arg.type);
|
|
57
|
+
arg.tags.forEach(tag => argState.tags.add(tag));
|
|
58
|
+
if (arg.type.endsWith('!')) {
|
|
59
|
+
argState.type = arg.type;
|
|
60
|
+
}
|
|
61
|
+
if (arg.deprecated && !argState.deprecated) {
|
|
62
|
+
argState.deprecated = arg.deprecated;
|
|
63
|
+
}
|
|
64
|
+
if (arg.description && !argState.description) {
|
|
65
|
+
argState.description = arg.description;
|
|
66
|
+
}
|
|
67
|
+
if (typeof arg.defaultValue === 'string') {
|
|
68
|
+
argState.defaultValue = arg.defaultValue;
|
|
69
|
+
}
|
|
70
|
+
arg.ast.directives.forEach(directive => {
|
|
71
|
+
argState.ast.directives.push(directive);
|
|
72
|
+
});
|
|
73
|
+
argState.byGraph.set(graph.id, {
|
|
74
|
+
type: arg.type,
|
|
75
|
+
defaultValue: arg.defaultValue,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
composeSupergraphNode(interfaceType, graphs) {
|
|
81
|
+
return (0, ast_js_1.createInterfaceTypeNode)({
|
|
82
|
+
name: interfaceType.name,
|
|
83
|
+
fields: Array.from(interfaceType.fields.values()).map(field => {
|
|
84
|
+
return {
|
|
85
|
+
name: field.name,
|
|
86
|
+
type: field.type,
|
|
87
|
+
inaccessible: field.inaccessible,
|
|
88
|
+
tags: Array.from(field.tags),
|
|
89
|
+
deprecated: field.deprecated,
|
|
90
|
+
description: field.description,
|
|
91
|
+
ast: {
|
|
92
|
+
directives: (0, common_js_1.convertToConst)(field.ast.directives),
|
|
93
|
+
},
|
|
94
|
+
arguments: Array.from(field.args.values())
|
|
95
|
+
.filter(arg => {
|
|
96
|
+
if (arg.byGraph.size !== field.byGraph.size) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
return true;
|
|
100
|
+
})
|
|
101
|
+
.map(arg => {
|
|
102
|
+
return {
|
|
103
|
+
name: arg.name,
|
|
104
|
+
type: arg.type,
|
|
105
|
+
tags: Array.from(arg.tags),
|
|
106
|
+
defaultValue: arg.defaultValue,
|
|
107
|
+
deprecated: arg.deprecated,
|
|
108
|
+
description: arg.description,
|
|
109
|
+
ast: {
|
|
110
|
+
directives: (0, common_js_1.convertToConst)(arg.ast.directives),
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}),
|
|
114
|
+
join: {
|
|
115
|
+
field: field.byGraph.size === interfaceType.byGraph.size
|
|
116
|
+
? []
|
|
117
|
+
: Array.from(field.byGraph.entries()).map(([graphName, meta]) => ({
|
|
118
|
+
graph: graphName.toUpperCase(),
|
|
119
|
+
type: meta.type === field.type ? undefined : meta.type,
|
|
120
|
+
override: meta.override ?? undefined,
|
|
121
|
+
provides: meta.provides ?? undefined,
|
|
122
|
+
requires: meta.requires ?? undefined,
|
|
123
|
+
})),
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}),
|
|
127
|
+
tags: Array.from(interfaceType.tags),
|
|
128
|
+
inaccessible: interfaceType.inaccessible,
|
|
129
|
+
description: interfaceType.description,
|
|
130
|
+
interfaces: Array.from(interfaceType.interfaces),
|
|
131
|
+
ast: {
|
|
132
|
+
directives: (0, common_js_1.convertToConst)(interfaceType.ast.directives),
|
|
133
|
+
},
|
|
134
|
+
join: {
|
|
135
|
+
type: Array.from(interfaceType.byGraph)
|
|
136
|
+
.map(([graphId, meta]) => {
|
|
137
|
+
if (meta.keys.length && graphs.get(graphId).version !== 'v1.0') {
|
|
138
|
+
return meta.keys.map(key => ({
|
|
139
|
+
graph: graphId,
|
|
140
|
+
key: key.fields,
|
|
141
|
+
extension: meta.extension,
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
144
|
+
return [
|
|
145
|
+
{
|
|
146
|
+
graph: graphId,
|
|
147
|
+
},
|
|
148
|
+
];
|
|
149
|
+
})
|
|
150
|
+
.flat(1),
|
|
151
|
+
implements: interfaceType.interfaces.size > 0
|
|
152
|
+
? Array.from(interfaceType.byGraph.entries())
|
|
153
|
+
.map(([graphId, meta]) => {
|
|
154
|
+
if (meta.interfaces.size) {
|
|
155
|
+
return Array.from(meta.interfaces).map(iface => ({
|
|
156
|
+
graph: graphId,
|
|
157
|
+
interface: iface,
|
|
158
|
+
}));
|
|
159
|
+
}
|
|
160
|
+
return [];
|
|
161
|
+
})
|
|
162
|
+
.flat(1)
|
|
163
|
+
: [],
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
exports.interfaceTypeBuilder = interfaceTypeBuilder;
|
|
170
|
+
function getOrCreateInterfaceType(state, typeName) {
|
|
171
|
+
const existing = state.get(typeName);
|
|
172
|
+
if (existing) {
|
|
173
|
+
return existing;
|
|
174
|
+
}
|
|
175
|
+
const def = {
|
|
176
|
+
name: typeName,
|
|
177
|
+
tags: new Set(),
|
|
178
|
+
inaccessible: false,
|
|
179
|
+
hasDefinition: false,
|
|
180
|
+
byGraph: new Map(),
|
|
181
|
+
fields: new Map(),
|
|
182
|
+
interfaces: new Set(),
|
|
183
|
+
implementedBy: new Set(),
|
|
184
|
+
ast: {
|
|
185
|
+
directives: [],
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
state.set(typeName, def);
|
|
189
|
+
return def;
|
|
190
|
+
}
|
|
191
|
+
function getOrCreateInterfaceField(interfaceTypeState, fieldName, fieldType) {
|
|
192
|
+
const existing = interfaceTypeState.fields.get(fieldName);
|
|
193
|
+
if (existing) {
|
|
194
|
+
return existing;
|
|
195
|
+
}
|
|
196
|
+
const def = {
|
|
197
|
+
name: fieldName,
|
|
198
|
+
type: fieldType,
|
|
199
|
+
tags: new Set(),
|
|
200
|
+
inaccessible: false,
|
|
201
|
+
byGraph: new Map(),
|
|
202
|
+
args: new Map(),
|
|
203
|
+
ast: {
|
|
204
|
+
directives: [],
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
interfaceTypeState.fields.set(fieldName, def);
|
|
208
|
+
return def;
|
|
209
|
+
}
|
|
210
|
+
function getOrCreateArg(fieldState, argName, argType) {
|
|
211
|
+
const existing = fieldState.args.get(argName);
|
|
212
|
+
if (existing) {
|
|
213
|
+
return existing;
|
|
214
|
+
}
|
|
215
|
+
const def = {
|
|
216
|
+
name: argName,
|
|
217
|
+
type: argType,
|
|
218
|
+
tags: new Set(),
|
|
219
|
+
byGraph: new Map(),
|
|
220
|
+
ast: {
|
|
221
|
+
directives: [],
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
fieldState.args.set(argName, def);
|
|
225
|
+
return def;
|
|
226
|
+
}
|