@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,85 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
export function FieldsOfTheSameTypeRule(context) {
|
|
3
|
+
return {
|
|
4
|
+
ObjectTypeField(objectTypeState, fieldState) {
|
|
5
|
+
const typeToGraphs = new Map();
|
|
6
|
+
fieldState.byGraph.forEach((field, graphName) => {
|
|
7
|
+
const isNullable = !field.type.endsWith('!');
|
|
8
|
+
const isNullableInSupergraph = !fieldState.type.endsWith('!');
|
|
9
|
+
const isMatchingNonNullablePart = fieldState.type.replace(/!$/, '') === field.type.replace(/!$/, '');
|
|
10
|
+
let normalizedOutputType;
|
|
11
|
+
if (isMatchingNonNullablePart) {
|
|
12
|
+
normalizedOutputType = isNullableInSupergraph
|
|
13
|
+
? isNullable
|
|
14
|
+
? field.type
|
|
15
|
+
: field.type.replace(/!$/, '')
|
|
16
|
+
: field.type;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
normalizedOutputType = field.type;
|
|
20
|
+
}
|
|
21
|
+
const existing = typeToGraphs.get(normalizedOutputType);
|
|
22
|
+
if (existing) {
|
|
23
|
+
existing.push(graphName);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
typeToGraphs.set(normalizedOutputType, [graphName]);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
if (typeToGraphs.size > 1) {
|
|
30
|
+
const groups = Array.from(typeToGraphs.entries()).map(([outputType, graphs]) => {
|
|
31
|
+
const plural = graphs.length > 1 ? 's' : '';
|
|
32
|
+
return `type "${outputType}" in subgraph${plural} "${graphs
|
|
33
|
+
.map(context.graphIdToName)
|
|
34
|
+
.join('", "')}"`;
|
|
35
|
+
});
|
|
36
|
+
const [first, second, ...rest] = groups;
|
|
37
|
+
context.reportError(new GraphQLError(`Type of field "${objectTypeState.name}.${fieldState.name}" is incompatible across subgraphs: it has ${first} but ${second}${rest.length ? ` and ${rest.join(' and ')}` : ''}`, {
|
|
38
|
+
extensions: {
|
|
39
|
+
code: 'FIELD_TYPE_MISMATCH',
|
|
40
|
+
},
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
InputObjectTypeField(inputObjectTypeState, fieldState) {
|
|
45
|
+
const typeToGraphs = new Map();
|
|
46
|
+
fieldState.byGraph.forEach((field, graphName) => {
|
|
47
|
+
const isNonNullable = field.type.endsWith('!');
|
|
48
|
+
const isNonNullableInSupergraph = fieldState.type.endsWith('!');
|
|
49
|
+
const isMatchingNonNullablePart = fieldState.type.replace(/!$/, '') === field.type.replace(/!$/, '');
|
|
50
|
+
let normalizedOutputType;
|
|
51
|
+
if (isMatchingNonNullablePart) {
|
|
52
|
+
normalizedOutputType = isNonNullableInSupergraph
|
|
53
|
+
? isNonNullable
|
|
54
|
+
? field.type
|
|
55
|
+
: field.type + '!'
|
|
56
|
+
: field.type;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
normalizedOutputType = field.type;
|
|
60
|
+
}
|
|
61
|
+
const existing = typeToGraphs.get(normalizedOutputType);
|
|
62
|
+
if (existing) {
|
|
63
|
+
existing.push(graphName);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
typeToGraphs.set(normalizedOutputType, [graphName]);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
if (typeToGraphs.size > 1) {
|
|
70
|
+
const groups = Array.from(typeToGraphs.entries()).map(([outputType, graphs]) => {
|
|
71
|
+
const plural = graphs.length > 1 ? 's' : '';
|
|
72
|
+
return `type "${outputType}" in subgraph${plural} "${graphs
|
|
73
|
+
.map(context.graphIdToName)
|
|
74
|
+
.join('", "')}"`;
|
|
75
|
+
});
|
|
76
|
+
const [first, second, ...rest] = groups;
|
|
77
|
+
context.reportError(new GraphQLError(`Type of field "${inputObjectTypeState.name}.${fieldState.name}" is incompatible across subgraphs: it has ${first} but ${second}${rest.length ? ` and ${rest.join(' and ')}` : ''}`, {
|
|
78
|
+
extensions: {
|
|
79
|
+
code: 'FIELD_TYPE_MISMATCH',
|
|
80
|
+
},
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
export function InputFieldDefaultMismatchRule(context) {
|
|
3
|
+
return {
|
|
4
|
+
InputObjectTypeField(inputObjectState, fieldState) {
|
|
5
|
+
if (typeof fieldState.defaultValue !== 'string') {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const defaultValueToGraphs = new Map();
|
|
9
|
+
fieldState.byGraph.forEach((field, graphName) => {
|
|
10
|
+
if (typeof field.defaultValue === 'string') {
|
|
11
|
+
const existing = defaultValueToGraphs.get(field.defaultValue);
|
|
12
|
+
if (existing) {
|
|
13
|
+
existing.push(graphName);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
defaultValueToGraphs.set(field.defaultValue, [graphName]);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
if (defaultValueToGraphs.size > 1) {
|
|
21
|
+
const groups = Array.from(defaultValueToGraphs.entries()).map(([defaultValue, graphs]) => {
|
|
22
|
+
const plural = graphs.length > 1 ? 's' : '';
|
|
23
|
+
return `default value ${defaultValue} in subgraph${plural} "${graphs
|
|
24
|
+
.map(context.graphIdToName)
|
|
25
|
+
.join('", "')}"`;
|
|
26
|
+
});
|
|
27
|
+
const [first, second, ...rest] = groups;
|
|
28
|
+
context.reportError(new GraphQLError(`Input field "${inputObjectState.name}.${fieldState.name}" has incompatible default values across subgraphs: it has ${first} but ${second}${rest.length ? ` and ${rest.join(' and ')}` : ''}`, {
|
|
29
|
+
extensions: {
|
|
30
|
+
code: 'INPUT_FIELD_DEFAULT_MISMATCH',
|
|
31
|
+
},
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
export function InputObjectValuesRule(context) {
|
|
3
|
+
return {
|
|
4
|
+
InputObjectType(inputObjectTypeState) {
|
|
5
|
+
const fieldsInCommon = [];
|
|
6
|
+
const total = inputObjectTypeState.byGraph.size;
|
|
7
|
+
for (const [fieldName, fieldState] of inputObjectTypeState.fields) {
|
|
8
|
+
if (fieldState.byGraph.size === total) {
|
|
9
|
+
fieldsInCommon.push(fieldName);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
if (fieldsInCommon.length === 0) {
|
|
13
|
+
context.reportError(new GraphQLError(`None of the fields of input object type "${inputObjectTypeState.name}" are consistently defined in all the subgraphs defining that type. As only fields common to all subgraphs are merged, this would result in an empty type.`, {
|
|
14
|
+
extensions: {
|
|
15
|
+
code: 'EMPTY_MERGED_INPUT_TYPE',
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
export function InterfaceKeyMissingImplementationTypeRule(context) {
|
|
3
|
+
return {
|
|
4
|
+
InterfaceType(interfaceState) {
|
|
5
|
+
let someSubgraphsAreMissingImplementation = false;
|
|
6
|
+
for (const interfaceStateInGraph of interfaceState.byGraph.values()) {
|
|
7
|
+
if (interfaceStateInGraph.keys.length === 0) {
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
if (interfaceStateInGraph.implementedBy.size === 0) {
|
|
11
|
+
someSubgraphsAreMissingImplementation = true;
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (!someSubgraphsAreMissingImplementation) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
for (const [graph, interfaceStateInGraph] of interfaceState.byGraph) {
|
|
19
|
+
if (interfaceStateInGraph.keys.length === 0) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const firstKeyFields = interfaceStateInGraph.keys[0].fields;
|
|
23
|
+
const graphName = context.graphIdToName(graph);
|
|
24
|
+
const typesToDefine = Array.from(interfaceState.implementedBy)
|
|
25
|
+
.filter(objectTypeName => !interfaceStateInGraph.implementedBy.has(objectTypeName))
|
|
26
|
+
.sort();
|
|
27
|
+
context.reportError(new GraphQLError(`[${graphName}] Interface type "${interfaceState.name}" has a resolvable key (@key(fields: "${firstKeyFields}")) in subgraph "${graphName}" but that subgraph is missing some of the supergraph implementation types of "${interfaceState.name}". Subgraph "${graphName}" should define ${typesToDefine.length > 1 ? 'types' : 'type'} ${joinWithAnd(typesToDefine)} (and have ${typesToDefine.length > 1 ? 'them' : 'it'} implement "${interfaceState.name}").`, {
|
|
28
|
+
extensions: {
|
|
29
|
+
code: 'INTERFACE_KEY_MISSING_IMPLEMENTATION_TYPE',
|
|
30
|
+
},
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function joinWithAnd(list) {
|
|
37
|
+
if (list.length <= 2) {
|
|
38
|
+
return `"${list.join('" and "')}"`;
|
|
39
|
+
}
|
|
40
|
+
const last = list.pop();
|
|
41
|
+
return `"${list.join('", "')}" and "${last}"`;
|
|
42
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
import { andList } from '../../../utils/format.js';
|
|
3
|
+
export function InvalidFieldSharingRule(context) {
|
|
4
|
+
return {
|
|
5
|
+
ObjectTypeField(objectTypeState, fieldState) {
|
|
6
|
+
if (fieldState.usedAsKey &&
|
|
7
|
+
Array.from(fieldState.byGraph.values()).every(field => field.usedAsKey)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const nonSharableIn = [];
|
|
11
|
+
const resolvableIn = [];
|
|
12
|
+
for (const [graphId, field] of fieldState.byGraph) {
|
|
13
|
+
const objectTypeIsShareable = objectTypeState.byGraph.get(graphId).shareable;
|
|
14
|
+
const fieldIsShareable = field.shareable;
|
|
15
|
+
const fieldIsExternal = field.external;
|
|
16
|
+
const fieldHasOverride = field.override;
|
|
17
|
+
const fieldIsUsedAsKey = field.usedAsKey;
|
|
18
|
+
if (fieldIsExternal || fieldHasOverride) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (objectTypeIsShareable || fieldIsShareable || fieldIsUsedAsKey) {
|
|
22
|
+
resolvableIn.push(graphId);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
nonSharableIn.push(graphId);
|
|
26
|
+
resolvableIn.push(graphId);
|
|
27
|
+
}
|
|
28
|
+
if (nonSharableIn.length >= 1 && resolvableIn.length > 1) {
|
|
29
|
+
const isNonSharableInAll = resolvableIn.every(graphId => nonSharableIn.includes(graphId));
|
|
30
|
+
const message = `Non-shareable field "${objectTypeState.name}.${fieldState.name}" is resolved from multiple subgraphs: it is resolved from subgraphs ${andList(resolvableIn.map(context.graphIdToName), false, '"')} and defined as non-shareable in ${isNonSharableInAll
|
|
31
|
+
? 'all of them'
|
|
32
|
+
: `subgraph${nonSharableIn.length > 1 ? 's' : ''} ${andList(nonSharableIn.map(context.graphIdToName), true, '"')}`}`;
|
|
33
|
+
context.reportError(new GraphQLError(message, {
|
|
34
|
+
extensions: {
|
|
35
|
+
code: 'INVALID_FIELD_SHARING',
|
|
36
|
+
},
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
export function OnlyInaccessibleChildrenRule(context) {
|
|
3
|
+
return {
|
|
4
|
+
EnumType(enumState) {
|
|
5
|
+
if (enumState.inaccessible === false && areAllInaccessible(enumState.values)) {
|
|
6
|
+
context.reportError(new GraphQLError(`Type "${enumState.name}" is in the API schema but all of its values are @inaccessible.`, {
|
|
7
|
+
extensions: {
|
|
8
|
+
code: 'ONLY_INACCESSIBLE_CHILDREN',
|
|
9
|
+
},
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
ObjectType(objectState) {
|
|
14
|
+
if (objectState.inaccessible === false && areAllInaccessible(objectState.fields)) {
|
|
15
|
+
context.reportError(new GraphQLError(`Type "${objectState.name}" is in the API schema but all of its fields are @inaccessible.`, {
|
|
16
|
+
extensions: {
|
|
17
|
+
code: 'ONLY_INACCESSIBLE_CHILDREN',
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
InputObjectType(inputObjectTypeState) {
|
|
23
|
+
if (inputObjectTypeState.inaccessible === false &&
|
|
24
|
+
areAllInaccessible(inputObjectTypeState.fields)) {
|
|
25
|
+
context.reportError(new GraphQLError(`Type "${inputObjectTypeState.name}" is in the API schema but all of its fields are @inaccessible.`, {
|
|
26
|
+
extensions: {
|
|
27
|
+
code: 'ONLY_INACCESSIBLE_CHILDREN',
|
|
28
|
+
},
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function areAllInaccessible(childrenMap) {
|
|
35
|
+
return Array.from(childrenMap.values()).every(f => f.inaccessible === true);
|
|
36
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
export function OverrideSourceHasOverrideRule(context) {
|
|
3
|
+
return {
|
|
4
|
+
ObjectTypeField(objectTypeState, fieldState) {
|
|
5
|
+
if (fieldState.override === null) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const graphsWithOverride = Array.from(fieldState.byGraph).filter(onlyWithOverride);
|
|
9
|
+
if (graphsWithOverride.length === 1) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
for (let i = 0; i < graphsWithOverride.length; i++) {
|
|
13
|
+
const [graph, fieldStateInGraph] = graphsWithOverride[i];
|
|
14
|
+
const overrideValue = fieldStateInGraph.override.toUpperCase();
|
|
15
|
+
const graphFromOverride = fieldState.byGraph.get(overrideValue);
|
|
16
|
+
const anotherGraphId = graphFromOverride && graphFromOverride.override !== null
|
|
17
|
+
? overrideValue
|
|
18
|
+
: graphsWithOverride[i + 1]
|
|
19
|
+
? graphsWithOverride[i + 1][0]
|
|
20
|
+
: graphsWithOverride[0][0];
|
|
21
|
+
context.reportError(new GraphQLError(`Field "${objectTypeState.name}.${fieldState.name}" on subgraph "${context.graphIdToName(graph)}" is also marked with directive @override in subgraph "${context.graphIdToName(anotherGraphId)}". Only one @override directive is allowed per field.`, {
|
|
22
|
+
extensions: {
|
|
23
|
+
code: 'OVERRIDE_SOURCE_HAS_OVERRIDE',
|
|
24
|
+
},
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function onlyWithOverride(entry) {
|
|
31
|
+
return entry[1].override !== null;
|
|
32
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
export function ReferencedInaccessibleRule(context, supergraph) {
|
|
3
|
+
return {
|
|
4
|
+
ObjectTypeField(objectState, fieldState) {
|
|
5
|
+
const outputTypeName = fieldState.type.replace(/[\[\]\!]+/g, '');
|
|
6
|
+
const referencesInaccessible = findOutputType(supergraph, outputTypeName)?.inaccessible === true;
|
|
7
|
+
const isInaccessible = fieldState.inaccessible === true || objectState.inaccessible === true;
|
|
8
|
+
if (referencesInaccessible && !isInaccessible) {
|
|
9
|
+
context.reportError(new GraphQLError(`Type "${outputTypeName}" is @inaccessible but is referenced by "${objectState.name}.${fieldState.name}", which is in the API schema.`, {
|
|
10
|
+
extensions: {
|
|
11
|
+
code: 'REFERENCED_INACCESSIBLE',
|
|
12
|
+
},
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
ObjectTypeFieldArg(objectState, fieldState, argState) {
|
|
17
|
+
const outputTypeName = argState.type.replace(/[\[\]\!]+/g, '');
|
|
18
|
+
const referencesInaccessible = findInputType(supergraph, outputTypeName)?.inaccessible === true;
|
|
19
|
+
const isInaccessible = argState.inaccessible === true ||
|
|
20
|
+
fieldState.inaccessible === true ||
|
|
21
|
+
objectState.inaccessible === true;
|
|
22
|
+
if (referencesInaccessible && !isInaccessible) {
|
|
23
|
+
context.reportError(new GraphQLError(`Type "${outputTypeName}" is @inaccessible but is referenced by "${objectState.name}.${fieldState.name}(${argState.name}:)", which is in the API schema.`, {
|
|
24
|
+
extensions: {
|
|
25
|
+
code: 'REFERENCED_INACCESSIBLE',
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function findOutputType(supergraph, typeName) {
|
|
33
|
+
return (supergraph.enumTypes.get(typeName) ||
|
|
34
|
+
supergraph.objectTypes.get(typeName) ||
|
|
35
|
+
supergraph.interfaceTypes.get(typeName) ||
|
|
36
|
+
supergraph.unionTypes.get(typeName));
|
|
37
|
+
}
|
|
38
|
+
function findInputType(supergraph, typeName) {
|
|
39
|
+
return supergraph.enumTypes.get(typeName) || supergraph.inputObjectTypes.get(typeName);
|
|
40
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
export function RequiredArgumentMissingInSomeSubgraph(context) {
|
|
3
|
+
return {
|
|
4
|
+
ObjectTypeFieldArg(objectState, fieldState, argState) {
|
|
5
|
+
if (argState.type.endsWith('!')) {
|
|
6
|
+
if (argState.byGraph.size === 1 && fieldState.byGraph.size === argState.byGraph.size) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (fieldState.byGraph.size === argState.byGraph.size) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const graphsWithRequiredArg = Array.from(argState.byGraph)
|
|
13
|
+
.filter(([_, arg]) => arg.type.endsWith('!'))
|
|
14
|
+
.map(([graph]) => graph);
|
|
15
|
+
const graphsWithoutArg = Array.from(fieldState.byGraph.keys()).filter(graph => !argState.byGraph.has(graph));
|
|
16
|
+
const requiredIn = `subgraph${graphsWithRequiredArg.length > 1 ? 's' : ''} "${graphsWithRequiredArg.map(context.graphIdToName).join('", "')}"`;
|
|
17
|
+
const missingIn = `subgraph${graphsWithoutArg.length > 1 ? 's' : ''} "${graphsWithoutArg
|
|
18
|
+
.map(context.graphIdToName)
|
|
19
|
+
.join('", "')}"`;
|
|
20
|
+
context.reportError(new GraphQLError(`Argument "${objectState.name}.${fieldState.name}(${argState.name}:)" is required in some subgraphs but does not appear in all subgraphs: it is required in ${requiredIn} but does not appear in ${missingIn}`, {
|
|
21
|
+
extensions: {
|
|
22
|
+
code: 'REQUIRED_ARGUMENT_MISSING_IN_SOME_SUBGRAPH',
|
|
23
|
+
},
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
export function RequiredInputFieldMissingInSomeSubgraphRule(context) {
|
|
3
|
+
return {
|
|
4
|
+
InputObjectTypeField(inputObjectState, fieldState) {
|
|
5
|
+
if (fieldState.type.endsWith('!')) {
|
|
6
|
+
if (inputObjectState.byGraph.size === 1) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (inputObjectState.byGraph.size === fieldState.byGraph.size) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const graphsWithRequiredField = Array.from(fieldState.byGraph)
|
|
13
|
+
.filter(([_, field]) => field.type.endsWith('!'))
|
|
14
|
+
.map(([graph]) => graph);
|
|
15
|
+
const graphsWithoutField = Array.from(inputObjectState.byGraph.keys()).filter(graph => !fieldState.byGraph.has(graph));
|
|
16
|
+
const requiredIn = `subgraph${graphsWithRequiredField.length > 1 ? 's' : ''} "${graphsWithRequiredField.map(context.graphIdToName).join('", "')}"`;
|
|
17
|
+
const missingIn = `subgraph${graphsWithoutField.length > 1 ? 's' : ''} "${graphsWithoutField
|
|
18
|
+
.map(context.graphIdToName)
|
|
19
|
+
.join('", "')}"`;
|
|
20
|
+
context.reportError(new GraphQLError(`Input object field "${inputObjectState.name}.${fieldState.name}" is required in some subgraphs but does not appear in all subgraphs: it is required in ${requiredIn} but does not appear in ${missingIn}`, {
|
|
21
|
+
extensions: {
|
|
22
|
+
code: 'REQUIRED_INPUT_FIELD_MISSING_IN_SOME_SUBGRAPH',
|
|
23
|
+
},
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
export function RequiredQueryRule(context) {
|
|
3
|
+
if (Array.from(context.subgraphStates.values()).every(subgraph => typeof subgraph.schema.queryType === 'undefined')) {
|
|
4
|
+
context.reportError(new GraphQLError(`No queries found in any subgraph: a supergraph must have a query root type.`, {
|
|
5
|
+
extensions: {
|
|
6
|
+
code: 'NO_QUERIES',
|
|
7
|
+
},
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
}
|