@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
package/LICENSE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 The Guild
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
6
|
+
associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
7
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
8
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
12
|
+
portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
15
|
+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
16
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
|
|
17
|
+
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/cjs/compose.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compositionHasErrors = exports.assertCompositionFailure = exports.assertCompositionSuccess = exports.composeServices = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
const printer_js_1 = require("./graphql/printer.js");
|
|
6
|
+
const inaccessible_js_1 = require("./specifications/inaccessible.js");
|
|
7
|
+
const join_js_1 = require("./specifications/join.js");
|
|
8
|
+
const link_js_1 = require("./specifications/link.js");
|
|
9
|
+
const tag_js_1 = require("./specifications/tag.js");
|
|
10
|
+
const validate_js_1 = require("./validate.js");
|
|
11
|
+
function composeServices(services, __internal) {
|
|
12
|
+
const validationResult = (0, validate_js_1.validate)(services, __internal);
|
|
13
|
+
if (!validationResult.success) {
|
|
14
|
+
return {
|
|
15
|
+
errors: validationResult.errors,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const rootTypes = {
|
|
19
|
+
query: false,
|
|
20
|
+
mutation: false,
|
|
21
|
+
subscription: false,
|
|
22
|
+
};
|
|
23
|
+
for (const def of validationResult.supergraph) {
|
|
24
|
+
if (def.name.value === 'Query') {
|
|
25
|
+
rootTypes.query = true;
|
|
26
|
+
}
|
|
27
|
+
else if (def.name.value === 'Mutation') {
|
|
28
|
+
rootTypes.mutation = true;
|
|
29
|
+
}
|
|
30
|
+
else if (def.name.value === 'Subscription') {
|
|
31
|
+
rootTypes.subscription = true;
|
|
32
|
+
}
|
|
33
|
+
if (rootTypes.query === true &&
|
|
34
|
+
rootTypes.mutation === true &&
|
|
35
|
+
rootTypes.subscription === true) {
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const usedTagSpec = validationResult.specs.tag;
|
|
40
|
+
const usedInaccessibleSpec = validationResult.specs.inaccessible;
|
|
41
|
+
return {
|
|
42
|
+
supergraphSdl: `
|
|
43
|
+
schema
|
|
44
|
+
@link(url: "https://specs.apollo.dev/link/v1.0")
|
|
45
|
+
@link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION)
|
|
46
|
+
${usedTagSpec ? '@link(url: "https://specs.apollo.dev/tag/v0.3")' : ''}
|
|
47
|
+
${usedInaccessibleSpec
|
|
48
|
+
? '@link(url: "https://specs.apollo.dev/inaccessible/v0.2", for: SECURITY)'
|
|
49
|
+
: ''}
|
|
50
|
+
${validationResult.links.map(link_js_1.printLink).join('\n ')}
|
|
51
|
+
{
|
|
52
|
+
${rootTypes.query ? 'query: Query' : ''}
|
|
53
|
+
${rootTypes.mutation ? 'mutation: Mutation' : ''}
|
|
54
|
+
${rootTypes.subscription ? 'subscription: Subscription' : ''}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
${join_js_1.sdl}
|
|
58
|
+
${link_js_1.sdl}
|
|
59
|
+
${usedTagSpec ? tag_js_1.sdl : ''}
|
|
60
|
+
${usedInaccessibleSpec ? inaccessible_js_1.sdl : ''}
|
|
61
|
+
|
|
62
|
+
${(0, printer_js_1.print)({
|
|
63
|
+
kind: graphql_1.Kind.DOCUMENT,
|
|
64
|
+
definitions: validationResult.supergraph,
|
|
65
|
+
})}
|
|
66
|
+
`,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
exports.composeServices = composeServices;
|
|
70
|
+
function assertCompositionSuccess(compositionResult, message) {
|
|
71
|
+
if (compositionHasErrors(compositionResult)) {
|
|
72
|
+
throw new Error(message || 'Unexpected test failure');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.assertCompositionSuccess = assertCompositionSuccess;
|
|
76
|
+
function assertCompositionFailure(compositionResult, message) {
|
|
77
|
+
if (!compositionHasErrors(compositionResult)) {
|
|
78
|
+
throw new Error(message || 'Unexpected test failure');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.assertCompositionFailure = assertCompositionFailure;
|
|
82
|
+
function compositionHasErrors(compositionResult) {
|
|
83
|
+
return 'errors' in compositionResult && !!compositionResult.errors;
|
|
84
|
+
}
|
|
85
|
+
exports.compositionHasErrors = compositionHasErrors;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stripFederationFromSupergraph = exports.isDirectiveDefinition = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function isDirectiveDefinition(node) {
|
|
6
|
+
return node.kind === graphql_1.Kind.DIRECTIVE_DEFINITION;
|
|
7
|
+
}
|
|
8
|
+
exports.isDirectiveDefinition = isDirectiveDefinition;
|
|
9
|
+
function stripFederationFromSupergraph(supergraph) {
|
|
10
|
+
function remove() {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return (0, graphql_1.visit)(supergraph, {
|
|
14
|
+
DirectiveDefinition: remove,
|
|
15
|
+
Directive: remove,
|
|
16
|
+
SchemaDefinition: remove,
|
|
17
|
+
SchemaExtension: remove,
|
|
18
|
+
EnumTypeDefinition: node => {
|
|
19
|
+
if (node.name.value === 'core__Purpose' || node.name.value === 'join__Graph') {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return node;
|
|
23
|
+
},
|
|
24
|
+
ScalarTypeDefinition: node => {
|
|
25
|
+
if (node.name.value === '_FieldSet') {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return node;
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.stripFederationFromSupergraph = stripFederationFromSupergraph;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.print = void 0;
|
|
4
|
+
function printString(string) {
|
|
5
|
+
return JSON.stringify(string);
|
|
6
|
+
}
|
|
7
|
+
function printBlockString(string) {
|
|
8
|
+
return '"""\n' + string.replace(/"""/g, '\\"""') + '\n"""';
|
|
9
|
+
}
|
|
10
|
+
const nodes = {
|
|
11
|
+
Document(node) {
|
|
12
|
+
return node.definitions?.length > 0 ? node.definitions.map(print).join('\n\n') : '';
|
|
13
|
+
},
|
|
14
|
+
OperationDefinition(node) {
|
|
15
|
+
if (node.operation === 'query' &&
|
|
16
|
+
!node.name &&
|
|
17
|
+
!node.variableDefinitions?.length &&
|
|
18
|
+
!node.directives?.length) {
|
|
19
|
+
return print(node.selectionSet);
|
|
20
|
+
}
|
|
21
|
+
return (join([
|
|
22
|
+
node.operation,
|
|
23
|
+
print(node.name) + wrap('(', join(node.variableDefinitions?.map(print), ', '), ')'),
|
|
24
|
+
join(node.directives?.map(print), ' '),
|
|
25
|
+
], ' ') + print(node.selectionSet));
|
|
26
|
+
},
|
|
27
|
+
VariableDefinition(node) {
|
|
28
|
+
return [
|
|
29
|
+
print(node.variable),
|
|
30
|
+
':',
|
|
31
|
+
print(node.type),
|
|
32
|
+
wrap(' = ', print(node.defaultValue)),
|
|
33
|
+
join(node.directives?.map(print), ' '),
|
|
34
|
+
].join(' ');
|
|
35
|
+
},
|
|
36
|
+
Field(node) {
|
|
37
|
+
return (join([
|
|
38
|
+
(node.alias ? node.alias.value + ': ' : '') + node.name.value + printArgs(node.arguments),
|
|
39
|
+
join(node.directives?.map(print), ' '),
|
|
40
|
+
], ' ') + print(node.selectionSet));
|
|
41
|
+
},
|
|
42
|
+
StringValue(node) {
|
|
43
|
+
return node.block ? printBlockString(node.value) : printString(node.value);
|
|
44
|
+
},
|
|
45
|
+
BooleanValue(node) {
|
|
46
|
+
return '' + node.value;
|
|
47
|
+
},
|
|
48
|
+
NullValue(_node) {
|
|
49
|
+
return 'null';
|
|
50
|
+
},
|
|
51
|
+
IntValue(node) {
|
|
52
|
+
return node.value;
|
|
53
|
+
},
|
|
54
|
+
FloatValue(node) {
|
|
55
|
+
return node.value;
|
|
56
|
+
},
|
|
57
|
+
EnumValue(node) {
|
|
58
|
+
return node.value;
|
|
59
|
+
},
|
|
60
|
+
Name(node) {
|
|
61
|
+
return node.value;
|
|
62
|
+
},
|
|
63
|
+
Variable(node) {
|
|
64
|
+
return '$' + node.name.value;
|
|
65
|
+
},
|
|
66
|
+
ListValue(node) {
|
|
67
|
+
return '[' + node.values.map(print).join(', ') + ']';
|
|
68
|
+
},
|
|
69
|
+
ObjectValue(node) {
|
|
70
|
+
return '{' + node.fields.map(print).join(', ') + '}';
|
|
71
|
+
},
|
|
72
|
+
ObjectField(node) {
|
|
73
|
+
return node.name.value + ': ' + print(node.value);
|
|
74
|
+
},
|
|
75
|
+
SelectionSet(node) {
|
|
76
|
+
return block(node.selections.map(print));
|
|
77
|
+
},
|
|
78
|
+
Argument(node) {
|
|
79
|
+
return node.name.value + ': ' + print(node.value);
|
|
80
|
+
},
|
|
81
|
+
FragmentSpread(node) {
|
|
82
|
+
return join(['...', print(node.name), join(node.directives?.map(print), ' ')], ' ');
|
|
83
|
+
},
|
|
84
|
+
InlineFragment(node) {
|
|
85
|
+
return join([
|
|
86
|
+
'...',
|
|
87
|
+
node.typeCondition ? 'on ' + node.typeCondition.name.value : '',
|
|
88
|
+
join(node.directives?.map(print), ' '),
|
|
89
|
+
print(node.selectionSet),
|
|
90
|
+
], ' ');
|
|
91
|
+
},
|
|
92
|
+
FragmentDefinition(node) {
|
|
93
|
+
return join([
|
|
94
|
+
'fragment',
|
|
95
|
+
print(node.name),
|
|
96
|
+
'on',
|
|
97
|
+
node.typeCondition.name.value,
|
|
98
|
+
join(node.directives?.map(print), ' '),
|
|
99
|
+
print(node.selectionSet),
|
|
100
|
+
]);
|
|
101
|
+
},
|
|
102
|
+
Directive(node) {
|
|
103
|
+
return '@' + node.name.value + printArgs(node.arguments);
|
|
104
|
+
},
|
|
105
|
+
NamedType(node) {
|
|
106
|
+
return node.name.value;
|
|
107
|
+
},
|
|
108
|
+
ListType(node) {
|
|
109
|
+
return '[' + print(node.type) + ']';
|
|
110
|
+
},
|
|
111
|
+
NonNullType(node) {
|
|
112
|
+
return print(node.type) + '!';
|
|
113
|
+
},
|
|
114
|
+
SchemaDefinition(node) {
|
|
115
|
+
return join(['schema', join(node.directives?.map(print), ' '), block(node.operationTypes?.map(print))], ' ');
|
|
116
|
+
},
|
|
117
|
+
OperationTypeDefinition(node) {
|
|
118
|
+
return node.operation + ': ' + print(node.type);
|
|
119
|
+
},
|
|
120
|
+
ScalarTypeDefinition(node) {
|
|
121
|
+
return (wrap('', print(node.description), '\n') +
|
|
122
|
+
join(['scalar', print(node.name), join(node.directives?.map(print), ' ')], ' '));
|
|
123
|
+
},
|
|
124
|
+
ObjectTypeDefinition(node) {
|
|
125
|
+
return (wrap('', print(node.description), '\n') +
|
|
126
|
+
join([
|
|
127
|
+
'type',
|
|
128
|
+
print(node.name),
|
|
129
|
+
wrap('implements ', join(node.interfaces?.map(print), ' & ')),
|
|
130
|
+
join(node.directives?.map(print), ' '),
|
|
131
|
+
block(node.fields?.map(print)),
|
|
132
|
+
], ' '));
|
|
133
|
+
},
|
|
134
|
+
InterfaceTypeDefinition(node) {
|
|
135
|
+
return (wrap('', print(node.description), '\n') +
|
|
136
|
+
join([
|
|
137
|
+
'interface',
|
|
138
|
+
print(node.name),
|
|
139
|
+
wrap('implements ', join(node.interfaces?.map(print), ' & ')),
|
|
140
|
+
join(node.directives?.map(print), ' '),
|
|
141
|
+
block(node.fields?.map(print)),
|
|
142
|
+
], ' '));
|
|
143
|
+
},
|
|
144
|
+
InputObjectTypeDefinition(node) {
|
|
145
|
+
return (wrap('', print(node.description), '\n') +
|
|
146
|
+
join([
|
|
147
|
+
'input',
|
|
148
|
+
print(node.name),
|
|
149
|
+
join(node.directives?.map(print), ' '),
|
|
150
|
+
block(node.fields?.map(print)),
|
|
151
|
+
], ' '));
|
|
152
|
+
},
|
|
153
|
+
UnionTypeDefinition(node) {
|
|
154
|
+
return (wrap('', print(node.description), '\n') +
|
|
155
|
+
join([
|
|
156
|
+
'union',
|
|
157
|
+
print(node.name),
|
|
158
|
+
join(node.directives?.map(print), ' '),
|
|
159
|
+
wrap('= ', join(node.types?.map(print), ' | ')),
|
|
160
|
+
], ' '));
|
|
161
|
+
},
|
|
162
|
+
EnumTypeDefinition(node) {
|
|
163
|
+
return (wrap('', print(node.description), '\n') +
|
|
164
|
+
join([
|
|
165
|
+
'enum',
|
|
166
|
+
print(node.name),
|
|
167
|
+
join(node.directives?.map(print), ' '),
|
|
168
|
+
block(node.values?.map(print)),
|
|
169
|
+
], ' '));
|
|
170
|
+
},
|
|
171
|
+
EnumValueDefinition(node) {
|
|
172
|
+
return (wrap('', print(node.description), '\n') +
|
|
173
|
+
join([print(node.name), join(node.directives?.map(print), ' ')], ' '));
|
|
174
|
+
},
|
|
175
|
+
FieldDefinition(node) {
|
|
176
|
+
return (wrap('', print(node.description), '\n') +
|
|
177
|
+
print(node.name) +
|
|
178
|
+
printArgs(node.arguments) +
|
|
179
|
+
': ' +
|
|
180
|
+
print(node.type) +
|
|
181
|
+
wrap(' ', join(node.directives?.map(print), ' ')));
|
|
182
|
+
},
|
|
183
|
+
InputValueDefinition(node) {
|
|
184
|
+
return (wrap('', print(node.description), '\n') +
|
|
185
|
+
join([
|
|
186
|
+
print(node.name) + ': ' + print(node.type),
|
|
187
|
+
wrap('= ', print(node.defaultValue)),
|
|
188
|
+
join(node.directives?.map(print), ' '),
|
|
189
|
+
], ' '));
|
|
190
|
+
},
|
|
191
|
+
DirectiveDefinition(node) {
|
|
192
|
+
return (wrap('', print(node.description), '\n') +
|
|
193
|
+
'directive @' +
|
|
194
|
+
print(node.name) +
|
|
195
|
+
printArgs(node.arguments) +
|
|
196
|
+
(node.repeatable ? ' repeatable' : '') +
|
|
197
|
+
' on ' +
|
|
198
|
+
join(node.locations?.map(print), ' | '));
|
|
199
|
+
},
|
|
200
|
+
SchemaExtension() {
|
|
201
|
+
return '';
|
|
202
|
+
},
|
|
203
|
+
ScalarTypeExtension() {
|
|
204
|
+
return '';
|
|
205
|
+
},
|
|
206
|
+
ObjectTypeExtension() {
|
|
207
|
+
return '';
|
|
208
|
+
},
|
|
209
|
+
InterfaceTypeExtension() {
|
|
210
|
+
return '';
|
|
211
|
+
},
|
|
212
|
+
UnionTypeExtension() {
|
|
213
|
+
return '';
|
|
214
|
+
},
|
|
215
|
+
EnumTypeExtension() {
|
|
216
|
+
return '';
|
|
217
|
+
},
|
|
218
|
+
InputObjectTypeExtension() {
|
|
219
|
+
return '';
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
function print(node) {
|
|
223
|
+
if (!node) {
|
|
224
|
+
return '';
|
|
225
|
+
}
|
|
226
|
+
return nodes[node.kind] ? nodes[node.kind](node) : '';
|
|
227
|
+
}
|
|
228
|
+
exports.print = print;
|
|
229
|
+
function printArgs(nodes) {
|
|
230
|
+
if (!nodes || nodes.length === 0) {
|
|
231
|
+
return '';
|
|
232
|
+
}
|
|
233
|
+
const args = nodes.map(print);
|
|
234
|
+
const argsLine = '(' + args.join(', ') + ') ';
|
|
235
|
+
return argsLine.length > 80 ? '(\n ' + args.join('\n').replace(/\n/g, '\n ') + '\n)' : argsLine;
|
|
236
|
+
}
|
|
237
|
+
function block(array) {
|
|
238
|
+
return wrap('{\n', indent(join(array, '\n')), '\n}');
|
|
239
|
+
}
|
|
240
|
+
function indent(str) {
|
|
241
|
+
return wrap(' ', str.replaceAll('\n', '\n '));
|
|
242
|
+
}
|
|
243
|
+
function wrap(start, maybeString, end = '') {
|
|
244
|
+
return maybeString != null && maybeString !== '' ? start + maybeString + end : '';
|
|
245
|
+
}
|
|
246
|
+
function join(maybeArray, separator = '') {
|
|
247
|
+
return maybeArray?.filter(x => x).join(separator) ?? '';
|
|
248
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.visitWithTypeNodeInfo = exports.TypeNodeInfo = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function getEnterLeaveForKind(visitor, kind) {
|
|
6
|
+
const kindVisitor = visitor[kind];
|
|
7
|
+
if (typeof kindVisitor === 'object') {
|
|
8
|
+
return kindVisitor;
|
|
9
|
+
}
|
|
10
|
+
if (typeof kindVisitor === 'function') {
|
|
11
|
+
return { enter: kindVisitor, leave: undefined };
|
|
12
|
+
}
|
|
13
|
+
return { enter: visitor.enter, leave: visitor.leave };
|
|
14
|
+
}
|
|
15
|
+
function isNode(maybeNode) {
|
|
16
|
+
const maybeKind = maybeNode?.kind;
|
|
17
|
+
return typeof maybeKind === 'string';
|
|
18
|
+
}
|
|
19
|
+
class TypeNodeInfo {
|
|
20
|
+
_type;
|
|
21
|
+
_field;
|
|
22
|
+
_arg;
|
|
23
|
+
_value;
|
|
24
|
+
constructor() {
|
|
25
|
+
this._type = undefined;
|
|
26
|
+
this._field = undefined;
|
|
27
|
+
this._arg = undefined;
|
|
28
|
+
this._value = undefined;
|
|
29
|
+
}
|
|
30
|
+
get [Symbol.toStringTag]() {
|
|
31
|
+
return 'TypeNodeInfo';
|
|
32
|
+
}
|
|
33
|
+
getTypeDef() {
|
|
34
|
+
return this._type;
|
|
35
|
+
}
|
|
36
|
+
getFieldDef() {
|
|
37
|
+
return this._field;
|
|
38
|
+
}
|
|
39
|
+
getArgumentDef() {
|
|
40
|
+
return this._arg;
|
|
41
|
+
}
|
|
42
|
+
getValueDef() {
|
|
43
|
+
return this._value;
|
|
44
|
+
}
|
|
45
|
+
enter(node) {
|
|
46
|
+
switch (node.kind) {
|
|
47
|
+
case graphql_1.Kind.OBJECT_TYPE_DEFINITION:
|
|
48
|
+
case graphql_1.Kind.OBJECT_TYPE_EXTENSION:
|
|
49
|
+
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
|
|
50
|
+
case graphql_1.Kind.INTERFACE_TYPE_EXTENSION:
|
|
51
|
+
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
52
|
+
case graphql_1.Kind.UNION_TYPE_EXTENSION:
|
|
53
|
+
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
54
|
+
case graphql_1.Kind.ENUM_TYPE_EXTENSION:
|
|
55
|
+
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
56
|
+
case graphql_1.Kind.INPUT_OBJECT_TYPE_EXTENSION:
|
|
57
|
+
case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
|
|
58
|
+
case graphql_1.Kind.SCALAR_TYPE_EXTENSION:
|
|
59
|
+
case graphql_1.Kind.DIRECTIVE_DEFINITION:
|
|
60
|
+
this._type = node;
|
|
61
|
+
break;
|
|
62
|
+
case graphql_1.Kind.ENUM_VALUE_DEFINITION:
|
|
63
|
+
this._value = node;
|
|
64
|
+
break;
|
|
65
|
+
case graphql_1.Kind.FIELD_DEFINITION:
|
|
66
|
+
this._field = node;
|
|
67
|
+
break;
|
|
68
|
+
case graphql_1.Kind.INPUT_VALUE_DEFINITION:
|
|
69
|
+
if (this._field) {
|
|
70
|
+
this._arg = node;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
this._field = node;
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
leave(node) {
|
|
80
|
+
switch (node.kind) {
|
|
81
|
+
case graphql_1.Kind.OBJECT_TYPE_DEFINITION:
|
|
82
|
+
case graphql_1.Kind.OBJECT_TYPE_EXTENSION:
|
|
83
|
+
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
|
|
84
|
+
case graphql_1.Kind.INTERFACE_TYPE_EXTENSION:
|
|
85
|
+
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
86
|
+
case graphql_1.Kind.UNION_TYPE_EXTENSION:
|
|
87
|
+
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
88
|
+
case graphql_1.Kind.ENUM_TYPE_EXTENSION:
|
|
89
|
+
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
90
|
+
case graphql_1.Kind.INPUT_OBJECT_TYPE_EXTENSION:
|
|
91
|
+
case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
|
|
92
|
+
case graphql_1.Kind.SCALAR_TYPE_EXTENSION:
|
|
93
|
+
case graphql_1.Kind.DIRECTIVE_DEFINITION:
|
|
94
|
+
this._type = undefined;
|
|
95
|
+
break;
|
|
96
|
+
case graphql_1.Kind.FIELD_DEFINITION:
|
|
97
|
+
this._field = undefined;
|
|
98
|
+
break;
|
|
99
|
+
case graphql_1.Kind.ENUM_VALUE_DEFINITION:
|
|
100
|
+
this._value = undefined;
|
|
101
|
+
break;
|
|
102
|
+
case graphql_1.Kind.INPUT_VALUE_DEFINITION:
|
|
103
|
+
if (this._arg) {
|
|
104
|
+
this._arg = undefined;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
this._field = undefined;
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
default:
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.TypeNodeInfo = TypeNodeInfo;
|
|
115
|
+
function visitWithTypeNodeInfo(typeInfo, visitor) {
|
|
116
|
+
return {
|
|
117
|
+
enter(node, key, parent, path, ancestors) {
|
|
118
|
+
typeInfo.enter(node);
|
|
119
|
+
const fn = getEnterLeaveForKind(visitor, node.kind).enter;
|
|
120
|
+
if (fn) {
|
|
121
|
+
const result = fn.call(visitor, node, key, parent, path, ancestors);
|
|
122
|
+
if (result !== undefined) {
|
|
123
|
+
typeInfo.leave(node);
|
|
124
|
+
if (isNode(result)) {
|
|
125
|
+
typeInfo.enter(result);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
leave(node, key, parent, path, ancestors) {
|
|
132
|
+
const fn = getEnterLeaveForKind(visitor, node.kind).leave;
|
|
133
|
+
let result;
|
|
134
|
+
if (fn) {
|
|
135
|
+
result = fn.call(visitor, node, key, parent, path, ancestors);
|
|
136
|
+
}
|
|
137
|
+
typeInfo.leave(node);
|
|
138
|
+
return result;
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
exports.visitWithTypeNodeInfo = visitWithTypeNodeInfo;
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.stripFederationFromSupergraph = void 0;
|
|
18
|
+
__exportStar(require("./compose.js"), exports);
|
|
19
|
+
__exportStar(require("./types.js"), exports);
|
|
20
|
+
__exportStar(require("./validate.js"), exports);
|
|
21
|
+
var helpers_js_1 = require("./graphql/helpers.js");
|
|
22
|
+
Object.defineProperty(exports, "stripFederationFromSupergraph", { enumerable: true, get: function () { return helpers_js_1.stripFederationFromSupergraph; } });
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|