@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,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProvidesRules = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
const printer_js_1 = require("../../../../graphql/printer.js");
|
|
6
|
+
const helpers_js_1 = require("../../../helpers.js");
|
|
7
|
+
function ProvidesRules(context) {
|
|
8
|
+
return {
|
|
9
|
+
DirectiveDefinition(node) {
|
|
10
|
+
(0, helpers_js_1.validateDirectiveAgainstOriginal)(node, 'provides', context);
|
|
11
|
+
},
|
|
12
|
+
Directive(directiveNode) {
|
|
13
|
+
if (!context.isAvailableFederationDirective('provides', directiveNode)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const annotatedType = context.typeNodeInfo.getTypeDef();
|
|
17
|
+
const annotatedField = context.typeNodeInfo.getFieldDef();
|
|
18
|
+
if (!annotatedType || !annotatedField) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const fieldCoordinate = `${annotatedType.name.value}.${annotatedField.name.value}`;
|
|
22
|
+
const usedOnInterface = annotatedType.kind === graphql_1.Kind.INTERFACE_TYPE_DEFINITION ||
|
|
23
|
+
annotatedType?.kind === graphql_1.Kind.INTERFACE_TYPE_EXTENSION;
|
|
24
|
+
const knownObjectsAndInterfaces = context.getSubgraphObjectOrInterfaceTypes();
|
|
25
|
+
const outputType = (0, helpers_js_1.namedTypeFromTypeNode)(annotatedField.type);
|
|
26
|
+
const targetType = knownObjectsAndInterfaces.get(outputType.name.value);
|
|
27
|
+
if (!targetType) {
|
|
28
|
+
context.reportError(new graphql_1.GraphQLError(`Invalid @provides directive on field "${fieldCoordinate}": field has type "${(0, printer_js_1.print)(annotatedField.type)}" which is not a Composite Type`, {
|
|
29
|
+
nodes: directiveNode,
|
|
30
|
+
extensions: {
|
|
31
|
+
code: 'PROVIDES_ON_NON_OBJECT_FIELD',
|
|
32
|
+
},
|
|
33
|
+
}));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (usedOnInterface) {
|
|
37
|
+
context.reportError(new graphql_1.GraphQLError(`Cannot use @provides on field "${fieldCoordinate}" of parent type "${annotatedType.name.value}": @provides is not yet supported within interfaces`, {
|
|
38
|
+
nodes: directiveNode,
|
|
39
|
+
extensions: { code: 'PROVIDES_UNSUPPORTED_ON_INTERFACE' },
|
|
40
|
+
}));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const fieldsArg = (0, helpers_js_1.getFieldsArgument)(directiveNode);
|
|
44
|
+
if (!fieldsArg) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const printedFieldsValue = (0, printer_js_1.print)(fieldsArg.value);
|
|
48
|
+
if (fieldsArg.value.kind !== graphql_1.Kind.STRING) {
|
|
49
|
+
context.reportError(new graphql_1.GraphQLError(`On field "${fieldCoordinate}", for @provides(fields: ${printedFieldsValue}): Invalid value for argument "fields": must be a string.`, {
|
|
50
|
+
nodes: directiveNode,
|
|
51
|
+
extensions: {
|
|
52
|
+
code: 'PROVIDES_INVALID_FIELDS_TYPE',
|
|
53
|
+
},
|
|
54
|
+
}));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
let selectionSet;
|
|
58
|
+
try {
|
|
59
|
+
selectionSet = (0, helpers_js_1.parseFields)(fieldsArg.value.value);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (error instanceof graphql_1.GraphQLError) {
|
|
63
|
+
context.reportError(new graphql_1.GraphQLError(`On field "${fieldCoordinate}", for @provides(fields: ${printedFieldsValue}): ${error.message}`, {
|
|
64
|
+
nodes: directiveNode,
|
|
65
|
+
extensions: {
|
|
66
|
+
code: 'PROVIDES_INVALID_FIELDS',
|
|
67
|
+
},
|
|
68
|
+
}));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
if (!selectionSet) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
let isValid = true;
|
|
77
|
+
(0, helpers_js_1.visitFields)({
|
|
78
|
+
context,
|
|
79
|
+
selectionSet,
|
|
80
|
+
typeDefinition: targetType,
|
|
81
|
+
interceptUnknownField(info) {
|
|
82
|
+
isValid = false;
|
|
83
|
+
context.reportError(new graphql_1.GraphQLError(`On field "${fieldCoordinate}", for @provides(fields: ${printedFieldsValue}): Cannot query field "${info.fieldName}" on type "${info.typeDefinition.name.value}" (if the field is defined in another subgraph, you need to add it to this subgraph with @external).`, { nodes: directiveNode, extensions: { code: 'PROVIDES_INVALID_FIELDS' } }));
|
|
84
|
+
},
|
|
85
|
+
interceptDirective(info) {
|
|
86
|
+
isValid = false;
|
|
87
|
+
if (info.isKnown) {
|
|
88
|
+
context.reportError(new graphql_1.GraphQLError(`On field "${fieldCoordinate}", for @provides(fields: ${printedFieldsValue}): cannot have directive applications in the @provides(fields:) argument but found @${info.directiveName}.`, {
|
|
89
|
+
nodes: directiveNode,
|
|
90
|
+
extensions: { code: 'PROVIDES_DIRECTIVE_IN_FIELDS_ARG' },
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
context.reportError(new graphql_1.GraphQLError(`On field "${fieldCoordinate}", for @provides(fields: ${printedFieldsValue}): Unknown directive "@${info.directiveName}" in selection`, {
|
|
95
|
+
nodes: directiveNode,
|
|
96
|
+
extensions: { code: 'PROVIDES_INVALID_FIELDS' },
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
interceptArguments(info) {
|
|
101
|
+
isValid = false;
|
|
102
|
+
context.reportError(new graphql_1.GraphQLError(`On field "${fieldCoordinate}", for @provides(fields: ${printedFieldsValue}): field ${info.typeDefinition.name.value}.${info.fieldName} cannot be included because it has arguments (fields with argument are not allowed in @provides)`, { nodes: directiveNode, extensions: { code: 'PROVIDES_FIELDS_HAS_ARGS' } }));
|
|
103
|
+
},
|
|
104
|
+
interceptNonExternalField(info) {
|
|
105
|
+
isValid = false;
|
|
106
|
+
context.reportError(new graphql_1.GraphQLError(`On field "${fieldCoordinate}", for @provides(fields: ${printedFieldsValue}): field "${info.typeDefinition.name.value}.${info.fieldName}" should not be part of a @provides since it is already provided by this subgraph (it is not marked @external)`, {
|
|
107
|
+
extensions: {
|
|
108
|
+
code: 'PROVIDES_FIELDS_MISSING_EXTERNAL',
|
|
109
|
+
},
|
|
110
|
+
}));
|
|
111
|
+
},
|
|
112
|
+
interceptExternalField(info) {
|
|
113
|
+
if (context.satisfiesVersionRange('< v2.0')) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const keyDirectives = info.typeDefinition.directives?.filter(directive => context.isAvailableFederationDirective('key', directive));
|
|
117
|
+
if (!keyDirectives?.length) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
let interceptedFieldIsPrimaryKeyFromExtension = false;
|
|
121
|
+
for (const keyDirective of keyDirectives) {
|
|
122
|
+
if (interceptedFieldIsPrimaryKeyFromExtension) {
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
const fieldsArg = keyDirective.arguments?.find(arg => arg.name.value === 'fields' && arg.value.kind === graphql_1.Kind.STRING);
|
|
126
|
+
if (fieldsArg) {
|
|
127
|
+
const keyFields = (0, helpers_js_1.parseFields)(fieldsArg.value.value);
|
|
128
|
+
if (keyFields) {
|
|
129
|
+
(0, helpers_js_1.visitFields)({
|
|
130
|
+
context,
|
|
131
|
+
selectionSet: keyFields,
|
|
132
|
+
typeDefinition: info.typeDefinition,
|
|
133
|
+
interceptField(keyFieldInfo) {
|
|
134
|
+
if (keyFieldInfo.typeDefinition.name.value === info.typeDefinition.name.value &&
|
|
135
|
+
keyFieldInfo.fieldName === info.fieldName) {
|
|
136
|
+
const isInterfaceType = keyFieldInfo.typeDefinition.kind === graphql_1.Kind.INTERFACE_TYPE_DEFINITION ||
|
|
137
|
+
keyFieldInfo.typeDefinition.kind === graphql_1.Kind.INTERFACE_TYPE_EXTENSION;
|
|
138
|
+
if (isInterfaceType) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const isExtension = keyFieldInfo.typeDefinition.kind === graphql_1.Kind.OBJECT_TYPE_EXTENSION ||
|
|
142
|
+
keyFieldInfo.typeDefinition.kind === graphql_1.Kind.INTERFACE_TYPE_EXTENSION ||
|
|
143
|
+
keyFieldInfo.typeDefinition.directives?.some(directive => context.isAvailableFederationDirective('extends', directive));
|
|
144
|
+
if (isExtension) {
|
|
145
|
+
interceptedFieldIsPrimaryKeyFromExtension = true;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (info.typeDefinition.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION ||
|
|
149
|
+
info.typeDefinition.kind === graphql_1.Kind.OBJECT_TYPE_EXTENSION) {
|
|
150
|
+
context.stateBuilder.objectType.field.markAsProvided(info.typeDefinition.name.value, info.fieldName);
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (interceptedFieldIsPrimaryKeyFromExtension) {
|
|
158
|
+
isValid = false;
|
|
159
|
+
context.reportError(new graphql_1.GraphQLError(`On field "${fieldCoordinate}", for @provides(fields: ${printedFieldsValue}): field "${info.typeDefinition.name.value}.${info.fieldName}" should not be part of a @provides since it is already "effectively" provided by this subgraph (while it is marked @external, it is a @key field of an extension type, which are not internally considered external for historical/backward compatibility reasons)`, {
|
|
160
|
+
extensions: {
|
|
161
|
+
code: 'PROVIDES_FIELDS_MISSING_EXTERNAL',
|
|
162
|
+
},
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
if (isValid) {
|
|
168
|
+
context.stateBuilder.objectType.field.setProvides(annotatedType.name.value, annotatedField.name.value, fieldsArg.value.value);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
exports.ProvidesRules = ProvidesRules;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RequiresRules = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
const printer_js_1 = require("../../../../graphql/printer.js");
|
|
6
|
+
const helpers_js_1 = require("../../../helpers.js");
|
|
7
|
+
function RequiresRules(context) {
|
|
8
|
+
return {
|
|
9
|
+
DirectiveDefinition(node) {
|
|
10
|
+
(0, helpers_js_1.validateDirectiveAgainstOriginal)(node, 'requires', context);
|
|
11
|
+
},
|
|
12
|
+
Directive(directiveNode) {
|
|
13
|
+
if (!context.isAvailableFederationDirective('requires', directiveNode)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const annotatedType = context.typeNodeInfo.getTypeDef();
|
|
17
|
+
const annotatedField = context.typeNodeInfo.getFieldDef();
|
|
18
|
+
if (!annotatedType || !annotatedField) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const fieldCoordinate = `${annotatedType.name.value}.${annotatedField.name.value}`;
|
|
22
|
+
const usedOnInterface = annotatedType.kind === graphql_1.Kind.INTERFACE_TYPE_DEFINITION ||
|
|
23
|
+
annotatedType?.kind === graphql_1.Kind.INTERFACE_TYPE_EXTENSION;
|
|
24
|
+
if (annotatedField && usedOnInterface) {
|
|
25
|
+
context.reportError(new graphql_1.GraphQLError(`Cannot use @requires on field "${fieldCoordinate}" of parent type "${annotatedType.name.value}": @requires is not yet supported within interfaces`, {
|
|
26
|
+
nodes: directiveNode,
|
|
27
|
+
extensions: { code: 'REQUIRES_UNSUPPORTED_ON_INTERFACE' },
|
|
28
|
+
}));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const fieldsArg = (0, helpers_js_1.getFieldsArgument)(directiveNode);
|
|
32
|
+
if (!fieldsArg) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const printedFieldsValue = (0, printer_js_1.print)(fieldsArg.value);
|
|
36
|
+
if (fieldsArg.value.kind !== graphql_1.Kind.STRING) {
|
|
37
|
+
context.reportError(new graphql_1.GraphQLError(`On field "${fieldCoordinate}", for @requires(fields: ${printedFieldsValue}): Invalid value for argument "fields": must be a string.`, {
|
|
38
|
+
nodes: directiveNode,
|
|
39
|
+
extensions: {
|
|
40
|
+
code: 'REQUIRES_INVALID_FIELDS_TYPE',
|
|
41
|
+
},
|
|
42
|
+
}));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
let selectionSet;
|
|
46
|
+
try {
|
|
47
|
+
selectionSet = (0, helpers_js_1.parseFields)(fieldsArg.value.value);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (error instanceof graphql_1.GraphQLError) {
|
|
51
|
+
context.reportError(new graphql_1.GraphQLError(`On field "${fieldCoordinate}", for @requires(fields: ${printedFieldsValue}): ${error.message}`, {
|
|
52
|
+
nodes: directiveNode,
|
|
53
|
+
extensions: {
|
|
54
|
+
code: 'REQUIRES_INVALID_FIELDS',
|
|
55
|
+
},
|
|
56
|
+
}));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
if (!selectionSet) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
let isValid = true;
|
|
65
|
+
if (annotatedType.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION &&
|
|
66
|
+
annotatedType.kind !== graphql_1.Kind.INTERFACE_TYPE_EXTENSION &&
|
|
67
|
+
annotatedType.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION &&
|
|
68
|
+
annotatedType.kind !== graphql_1.Kind.OBJECT_TYPE_EXTENSION) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
(0, helpers_js_1.visitFields)({
|
|
72
|
+
context,
|
|
73
|
+
selectionSet,
|
|
74
|
+
typeDefinition: annotatedType,
|
|
75
|
+
interceptField(info) {
|
|
76
|
+
if (info.typeDefinition.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION ||
|
|
77
|
+
info.typeDefinition.kind === graphql_1.Kind.OBJECT_TYPE_EXTENSION) {
|
|
78
|
+
context.stateBuilder.objectType.field.markedAsRequired(info.typeDefinition.name.value, info.fieldName);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
interceptUnknownField(info) {
|
|
82
|
+
isValid = false;
|
|
83
|
+
context.reportError(new graphql_1.GraphQLError(`On field "${fieldCoordinate}", for @requires(fields: ${printedFieldsValue}): Cannot query field "${info.fieldName}" on type "${info.typeDefinition.name.value}" (if the field is defined in another subgraph, you need to add it to this subgraph with @external).`, { nodes: directiveNode, extensions: { code: 'REQUIRES_INVALID_FIELDS' } }));
|
|
84
|
+
},
|
|
85
|
+
interceptDirective(info) {
|
|
86
|
+
isValid = false;
|
|
87
|
+
if (info.isKnown) {
|
|
88
|
+
context.reportError(new graphql_1.GraphQLError(`On field "${fieldCoordinate}", for @requires(fields: ${printedFieldsValue}): cannot have directive applications in the @requires(fields:) argument but found @${info.directiveName}.`, {
|
|
89
|
+
nodes: directiveNode,
|
|
90
|
+
extensions: { code: 'REQUIRES_DIRECTIVE_IN_FIELDS_ARG' },
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
context.reportError(new graphql_1.GraphQLError(`On field "${fieldCoordinate}", for @requires(fields: ${printedFieldsValue}): Unknown directive "@${info.directiveName}" in selection`, {
|
|
95
|
+
nodes: directiveNode,
|
|
96
|
+
extensions: { code: 'REQUIRES_INVALID_FIELDS' },
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
interceptNonExternalField(info) {
|
|
101
|
+
isValid = false;
|
|
102
|
+
context.reportError(new graphql_1.GraphQLError(`On field "${fieldCoordinate}", for @requires(fields: ${printedFieldsValue}): field "${info.typeDefinition.name.value}.${info.fieldName}" should not be part of a @requires since it is already provided by this subgraph (it is not marked @external)`, {
|
|
103
|
+
extensions: {
|
|
104
|
+
code: 'REQUIRES_FIELDS_MISSING_EXTERNAL',
|
|
105
|
+
},
|
|
106
|
+
}));
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
if (isValid) {
|
|
110
|
+
if (usedOnInterface) {
|
|
111
|
+
context.stateBuilder.interfaceType.field.setRequires(annotatedType.name.value, annotatedField.name.value, fieldsArg.value.value);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
context.stateBuilder.objectType.field.setRequires(annotatedType.name.value, annotatedField.name.value, fieldsArg.value.value);
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
exports.RequiresRules = RequiresRules;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ShareableRules = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
const helpers_js_1 = require("../../../helpers.js");
|
|
6
|
+
function ShareableRules(context) {
|
|
7
|
+
return {
|
|
8
|
+
DirectiveDefinition(node) {
|
|
9
|
+
(0, helpers_js_1.validateDirectiveAgainstOriginal)(node, 'shareable', context);
|
|
10
|
+
},
|
|
11
|
+
Directive(node) {
|
|
12
|
+
if (!context.isAvailableFederationDirective('shareable', node)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const typeDef = context.typeNodeInfo.getTypeDef();
|
|
16
|
+
const fieldDef = context.typeNodeInfo.getFieldDef();
|
|
17
|
+
if (!typeDef) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (typeDef.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION ||
|
|
21
|
+
typeDef.kind === graphql_1.Kind.OBJECT_TYPE_EXTENSION) {
|
|
22
|
+
if (fieldDef) {
|
|
23
|
+
context.stateBuilder.objectType.field.setShareable(typeDef.name.value, fieldDef.name.value);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
context.stateBuilder.objectType.setShareable(typeDef.name.value);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!fieldDef) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (typeDef.kind === graphql_1.Kind.INTERFACE_TYPE_DEFINITION ||
|
|
33
|
+
typeDef.kind === graphql_1.Kind.INTERFACE_TYPE_EXTENSION) {
|
|
34
|
+
context.reportError(new graphql_1.GraphQLError(`Invalid use of @shareable on field "${typeDef.name.value}.${fieldDef.name.value}": only object type fields can be marked with @shareable`, {
|
|
35
|
+
nodes: node,
|
|
36
|
+
extensions: { code: 'INVALID_SHAREABLE_USAGE' },
|
|
37
|
+
}));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
exports.ShareableRules = ShareableRules;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TagRules = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
const helpers_js_1 = require("../../../helpers.js");
|
|
6
|
+
function TagRules(context) {
|
|
7
|
+
return {
|
|
8
|
+
DirectiveDefinition(node) {
|
|
9
|
+
(0, helpers_js_1.validateDirectiveAgainstOriginal)(node, 'tag', context);
|
|
10
|
+
},
|
|
11
|
+
Directive(node, _key, _parent, paths, ancestors) {
|
|
12
|
+
if (!context.isAvailableFederationDirective('tag', node)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const nameArg = node.arguments?.find(arg => arg.name.value === 'name');
|
|
16
|
+
if (!nameArg) {
|
|
17
|
+
throw new Error('Expected @tag to have a "name" argument');
|
|
18
|
+
}
|
|
19
|
+
if (nameArg.value.kind !== graphql_1.Kind.STRING) {
|
|
20
|
+
throw new Error('Expected "@tag(name:)" to be a string');
|
|
21
|
+
}
|
|
22
|
+
const directivesKeyAt = paths.findIndex(path => path === 'directives');
|
|
23
|
+
if (directivesKeyAt === -1) {
|
|
24
|
+
throw new Error('Could not find "directives" key in ancestors');
|
|
25
|
+
}
|
|
26
|
+
const parent = ancestors[directivesKeyAt];
|
|
27
|
+
if (!parent) {
|
|
28
|
+
throw new Error('Could not find the node annotated with @inaccessible');
|
|
29
|
+
}
|
|
30
|
+
if (Array.isArray(parent)) {
|
|
31
|
+
throw new Error('Expected parent to be a single node');
|
|
32
|
+
}
|
|
33
|
+
if (!('kind' in parent)) {
|
|
34
|
+
throw new Error('Expected parent to be a node');
|
|
35
|
+
}
|
|
36
|
+
const tag = nameArg.value.value;
|
|
37
|
+
switch (parent.kind) {
|
|
38
|
+
case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
|
|
39
|
+
case graphql_1.Kind.SCALAR_TYPE_EXTENSION:
|
|
40
|
+
context.stateBuilder.scalarType.setTag(parent.name.value, tag);
|
|
41
|
+
break;
|
|
42
|
+
case graphql_1.Kind.FIELD_DEFINITION: {
|
|
43
|
+
const typeDef = context.typeNodeInfo.getTypeDef();
|
|
44
|
+
if (!typeDef) {
|
|
45
|
+
throw new Error('Could not find the parent type of the field annotated with @tag');
|
|
46
|
+
}
|
|
47
|
+
if (typeDef.kind === graphql_1.Kind.INTERFACE_TYPE_DEFINITION ||
|
|
48
|
+
typeDef.kind === graphql_1.Kind.INTERFACE_TYPE_EXTENSION) {
|
|
49
|
+
context.stateBuilder.interfaceType.field.setTag(typeDef.name.value, parent.name.value, tag);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
context.stateBuilder.objectType.field.setTag(typeDef.name.value, parent.name.value, tag);
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
case graphql_1.Kind.INPUT_VALUE_DEFINITION: {
|
|
57
|
+
const typeDef = context.typeNodeInfo.getTypeDef();
|
|
58
|
+
if (!typeDef) {
|
|
59
|
+
throw new Error('Could not find the parent type of the field annotated with @tag');
|
|
60
|
+
}
|
|
61
|
+
if (typeDef.kind === graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION ||
|
|
62
|
+
typeDef.kind === graphql_1.Kind.INPUT_OBJECT_TYPE_EXTENSION) {
|
|
63
|
+
context.stateBuilder.inputObjectType.field.setTag(typeDef.name.value, parent.name.value, tag);
|
|
64
|
+
}
|
|
65
|
+
else if (typeDef.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION ||
|
|
66
|
+
typeDef.kind === graphql_1.Kind.OBJECT_TYPE_EXTENSION) {
|
|
67
|
+
const fieldDef = context.typeNodeInfo.getFieldDef();
|
|
68
|
+
if (!fieldDef) {
|
|
69
|
+
throw new Error('Could not find the parent field of the input value annotated with @tag');
|
|
70
|
+
}
|
|
71
|
+
context.stateBuilder.objectType.field.arg.setTag(typeDef.name.value, fieldDef.name.value, parent.name.value, tag);
|
|
72
|
+
}
|
|
73
|
+
else if (typeDef.kind === graphql_1.Kind.INTERFACE_TYPE_DEFINITION ||
|
|
74
|
+
typeDef.kind === graphql_1.Kind.INTERFACE_TYPE_EXTENSION) {
|
|
75
|
+
const fieldDef = context.typeNodeInfo.getFieldDef();
|
|
76
|
+
if (!fieldDef) {
|
|
77
|
+
throw new Error('Could not find the parent field of the input value annotated with @tag');
|
|
78
|
+
}
|
|
79
|
+
context.stateBuilder.interfaceType.field.arg.setTag(typeDef.name.value, fieldDef.name.value, parent.name.value, tag);
|
|
80
|
+
}
|
|
81
|
+
else if (typeDef.kind === graphql_1.Kind.DIRECTIVE_DEFINITION) {
|
|
82
|
+
context.stateBuilder.directive.arg.setTag(typeDef.name.value, parent.name.value, tag);
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case graphql_1.Kind.OBJECT_TYPE_DEFINITION:
|
|
87
|
+
case graphql_1.Kind.OBJECT_TYPE_EXTENSION:
|
|
88
|
+
context.stateBuilder.objectType.setTag(parent.name.value, tag);
|
|
89
|
+
break;
|
|
90
|
+
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
|
|
91
|
+
case graphql_1.Kind.INTERFACE_TYPE_EXTENSION:
|
|
92
|
+
context.stateBuilder.interfaceType.setTag(parent.name.value, tag);
|
|
93
|
+
break;
|
|
94
|
+
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
95
|
+
case graphql_1.Kind.UNION_TYPE_EXTENSION:
|
|
96
|
+
context.stateBuilder.unionType.setTag(parent.name.value, tag);
|
|
97
|
+
break;
|
|
98
|
+
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
99
|
+
case graphql_1.Kind.INPUT_OBJECT_TYPE_EXTENSION:
|
|
100
|
+
context.stateBuilder.inputObjectType.setTag(parent.name.value, tag);
|
|
101
|
+
break;
|
|
102
|
+
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
103
|
+
case graphql_1.Kind.ENUM_TYPE_EXTENSION:
|
|
104
|
+
context.stateBuilder.enumType.setTag(parent.name.value, tag);
|
|
105
|
+
break;
|
|
106
|
+
case graphql_1.Kind.ENUM_VALUE_DEFINITION: {
|
|
107
|
+
const enumValue = parent.name.value;
|
|
108
|
+
const typeDef = context.typeNodeInfo.getTypeDef();
|
|
109
|
+
if (!typeDef) {
|
|
110
|
+
throw new Error('Could not find the parent type of the enum value annotated with @tag');
|
|
111
|
+
}
|
|
112
|
+
context.stateBuilder.enumType.value.setTag(typeDef.name.value, enumValue, tag);
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
context.stateBuilder.markSpecAsUsed('tag');
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
exports.TagRules = TagRules;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KnownArgumentNamesOnDirectivesRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function KnownArgumentNamesOnDirectivesRule(context) {
|
|
6
|
+
const directiveArgs = new Map();
|
|
7
|
+
const astDefinitions = context.getDocument().definitions;
|
|
8
|
+
for (const def of astDefinitions) {
|
|
9
|
+
if (def.kind === graphql_1.Kind.DIRECTIVE_DEFINITION) {
|
|
10
|
+
const argsNodes = def.arguments ?? [];
|
|
11
|
+
directiveArgs.set(def.name.value, new Set(argsNodes.map(arg => arg.name.value)));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
Directive(directiveNode) {
|
|
16
|
+
const directiveName = directiveNode.name.value;
|
|
17
|
+
const knownArgs = directiveArgs.get(directiveName);
|
|
18
|
+
if (directiveNode.arguments && knownArgs) {
|
|
19
|
+
for (const argNode of directiveNode.arguments) {
|
|
20
|
+
const argName = argNode.name.value;
|
|
21
|
+
if (!knownArgs.has(argName)) {
|
|
22
|
+
context.reportError(new graphql_1.GraphQLError(`Unknown argument "${argName}" on directive "@${directiveName}".`, {
|
|
23
|
+
nodes: argNode,
|
|
24
|
+
extensions: {
|
|
25
|
+
code: 'INVALID_GRAPHQL',
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
exports.KnownArgumentNamesOnDirectivesRule = KnownArgumentNamesOnDirectivesRule;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KnownDirectivesRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function KnownDirectivesRule(context) {
|
|
6
|
+
const locationsMap = new Map();
|
|
7
|
+
const astDefinitions = context.getDocument().definitions;
|
|
8
|
+
for (const def of astDefinitions) {
|
|
9
|
+
if (def.kind === graphql_1.Kind.DIRECTIVE_DEFINITION) {
|
|
10
|
+
locationsMap.set(def.name.value, new Set(def.locations.map(name => name.value)));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
for (const specifiedDirective of graphql_1.specifiedDirectives) {
|
|
14
|
+
locationsMap.set(specifiedDirective.name, new Set(specifiedDirective.locations.map(loc => String(loc))));
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
Directive(node, _key, _parent, _path, ancestors) {
|
|
18
|
+
const name = node.name.value;
|
|
19
|
+
const locations = locationsMap.get(name);
|
|
20
|
+
if (!locations) {
|
|
21
|
+
context.reportError(new graphql_1.GraphQLError(`Unknown directive "@${name}".`, {
|
|
22
|
+
nodes: node,
|
|
23
|
+
extensions: {
|
|
24
|
+
code: 'INVALID_GRAPHQL',
|
|
25
|
+
},
|
|
26
|
+
}));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const candidateLocation = getDirectiveLocationForASTPath(ancestors);
|
|
30
|
+
if (candidateLocation && !locations.has(candidateLocation)) {
|
|
31
|
+
context.reportError(new graphql_1.GraphQLError(`Directive "@${name}" may not be used on ${candidateLocation}.`, {
|
|
32
|
+
nodes: node,
|
|
33
|
+
extensions: {
|
|
34
|
+
code: 'INVALID_GRAPHQL',
|
|
35
|
+
},
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.KnownDirectivesRule = KnownDirectivesRule;
|
|
42
|
+
function getDirectiveLocationForASTPath(ancestors) {
|
|
43
|
+
const appliedTo = ancestors[ancestors.length - 1];
|
|
44
|
+
if (!('kind' in appliedTo)) {
|
|
45
|
+
throw new Error('Expected a node');
|
|
46
|
+
}
|
|
47
|
+
switch (appliedTo.kind) {
|
|
48
|
+
case graphql_1.Kind.OPERATION_DEFINITION:
|
|
49
|
+
return getDirectiveLocationForOperation(appliedTo.operation);
|
|
50
|
+
case graphql_1.Kind.FIELD:
|
|
51
|
+
return graphql_1.DirectiveLocation.FIELD;
|
|
52
|
+
case graphql_1.Kind.FRAGMENT_SPREAD:
|
|
53
|
+
return graphql_1.DirectiveLocation.FRAGMENT_SPREAD;
|
|
54
|
+
case graphql_1.Kind.INLINE_FRAGMENT:
|
|
55
|
+
return graphql_1.DirectiveLocation.INLINE_FRAGMENT;
|
|
56
|
+
case graphql_1.Kind.FRAGMENT_DEFINITION:
|
|
57
|
+
return graphql_1.DirectiveLocation.FRAGMENT_DEFINITION;
|
|
58
|
+
case graphql_1.Kind.VARIABLE_DEFINITION:
|
|
59
|
+
return graphql_1.DirectiveLocation.VARIABLE_DEFINITION;
|
|
60
|
+
case graphql_1.Kind.SCHEMA_DEFINITION:
|
|
61
|
+
case graphql_1.Kind.SCHEMA_EXTENSION:
|
|
62
|
+
return graphql_1.DirectiveLocation.SCHEMA;
|
|
63
|
+
case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
|
|
64
|
+
case graphql_1.Kind.SCALAR_TYPE_EXTENSION:
|
|
65
|
+
return graphql_1.DirectiveLocation.SCALAR;
|
|
66
|
+
case graphql_1.Kind.OBJECT_TYPE_DEFINITION:
|
|
67
|
+
case graphql_1.Kind.OBJECT_TYPE_EXTENSION:
|
|
68
|
+
return graphql_1.DirectiveLocation.OBJECT;
|
|
69
|
+
case graphql_1.Kind.FIELD_DEFINITION:
|
|
70
|
+
return graphql_1.DirectiveLocation.FIELD_DEFINITION;
|
|
71
|
+
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
|
|
72
|
+
case graphql_1.Kind.INTERFACE_TYPE_EXTENSION:
|
|
73
|
+
return graphql_1.DirectiveLocation.INTERFACE;
|
|
74
|
+
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
75
|
+
case graphql_1.Kind.UNION_TYPE_EXTENSION:
|
|
76
|
+
return graphql_1.DirectiveLocation.UNION;
|
|
77
|
+
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
78
|
+
case graphql_1.Kind.ENUM_TYPE_EXTENSION:
|
|
79
|
+
return graphql_1.DirectiveLocation.ENUM;
|
|
80
|
+
case graphql_1.Kind.ENUM_VALUE_DEFINITION:
|
|
81
|
+
return graphql_1.DirectiveLocation.ENUM_VALUE;
|
|
82
|
+
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
83
|
+
case graphql_1.Kind.INPUT_OBJECT_TYPE_EXTENSION:
|
|
84
|
+
return graphql_1.DirectiveLocation.INPUT_OBJECT;
|
|
85
|
+
case graphql_1.Kind.INPUT_VALUE_DEFINITION: {
|
|
86
|
+
const parentNode = ancestors[ancestors.length - 3];
|
|
87
|
+
if (!('kind' in parentNode)) {
|
|
88
|
+
throw new Error('Expected a node');
|
|
89
|
+
}
|
|
90
|
+
return parentNode.kind === graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION
|
|
91
|
+
? graphql_1.DirectiveLocation.INPUT_FIELD_DEFINITION
|
|
92
|
+
: graphql_1.DirectiveLocation.ARGUMENT_DEFINITION;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function getDirectiveLocationForOperation(operation) {
|
|
97
|
+
switch (operation) {
|
|
98
|
+
case graphql_1.OperationTypeNode.QUERY:
|
|
99
|
+
return graphql_1.DirectiveLocation.QUERY;
|
|
100
|
+
case graphql_1.OperationTypeNode.MUTATION:
|
|
101
|
+
return graphql_1.DirectiveLocation.MUTATION;
|
|
102
|
+
case graphql_1.OperationTypeNode.SUBSCRIPTION:
|
|
103
|
+
return graphql_1.DirectiveLocation.SUBSCRIPTION;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KnownFederationDirectivesRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function KnownFederationDirectivesRule(context) {
|
|
6
|
+
const availableDirectivesSet = new Set();
|
|
7
|
+
const knownDirectivesSet = new Set();
|
|
8
|
+
const knownDirectives = context.getKnownFederationDirectives();
|
|
9
|
+
for (const directive of knownDirectives) {
|
|
10
|
+
knownDirectivesSet.add(directive.name.value);
|
|
11
|
+
}
|
|
12
|
+
const availableDirectives = context.getAvailableFederationDirectives();
|
|
13
|
+
for (const directive of availableDirectives) {
|
|
14
|
+
availableDirectivesSet.add(directive.name.value);
|
|
15
|
+
}
|
|
16
|
+
const astDefinitions = context.getDocument().definitions;
|
|
17
|
+
for (const def of astDefinitions) {
|
|
18
|
+
if (def.kind === graphql_1.Kind.DIRECTIVE_DEFINITION) {
|
|
19
|
+
availableDirectivesSet.add(def.name.value);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
Directive(node) {
|
|
24
|
+
const name = node.name.value;
|
|
25
|
+
if (!availableDirectivesSet.has(name) &&
|
|
26
|
+
knownDirectivesSet.has(name) &&
|
|
27
|
+
!name.startsWith('federation__')) {
|
|
28
|
+
context.reportError(new graphql_1.GraphQLError(`Unknown directive "@${name}". If you meant the "@${name}" federation directive, you should use fully-qualified name "@federation__${name}" or add "@${name}" to the \`import\` argument of the @link to the federation specification.`, { nodes: node, extensions: { code: 'INVALID_GRAPHQL' } }));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
exports.KnownFederationDirectivesRule = KnownFederationDirectivesRule;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KnownRootTypeRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function KnownRootTypeRule(context) {
|
|
6
|
+
const { definitions } = context.getDocument();
|
|
7
|
+
const typeNames = new Set(definitions.filter(isTypeDefinitionOrExtensionNode).map(def => def.name.value));
|
|
8
|
+
return {
|
|
9
|
+
SchemaDefinition(node) {
|
|
10
|
+
node.operationTypes.forEach(operationType => {
|
|
11
|
+
if (!typeNames.has(operationType.type.name.value)) {
|
|
12
|
+
context.reportError(new graphql_1.GraphQLError(`Cannot set schema ${operationType.operation} root to unknown type ${operationType.type.name.value}`, {
|
|
13
|
+
extensions: {
|
|
14
|
+
code: 'INVALID_GRAPHQL',
|
|
15
|
+
},
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.KnownRootTypeRule = KnownRootTypeRule;
|
|
23
|
+
function isTypeDefinitionOrExtensionNode(node) {
|
|
24
|
+
return (0, graphql_1.isTypeDefinitionNode)(node) || (0, graphql_1.isTypeExtensionNode)(node);
|
|
25
|
+
}
|