@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,210 @@
|
|
|
1
|
+
import { Kind } from 'graphql';
|
|
2
|
+
import JSON5 from 'json5';
|
|
3
|
+
import { print } from '../graphql/printer.js';
|
|
4
|
+
export function printLink(link) {
|
|
5
|
+
return print({
|
|
6
|
+
kind: Kind.DIRECTIVE,
|
|
7
|
+
name: {
|
|
8
|
+
kind: Kind.NAME,
|
|
9
|
+
value: 'link',
|
|
10
|
+
},
|
|
11
|
+
arguments: [
|
|
12
|
+
{
|
|
13
|
+
kind: Kind.ARGUMENT,
|
|
14
|
+
name: {
|
|
15
|
+
kind: Kind.NAME,
|
|
16
|
+
value: 'url',
|
|
17
|
+
},
|
|
18
|
+
value: {
|
|
19
|
+
kind: Kind.STRING,
|
|
20
|
+
value: [link.identity, link.version].filter(Boolean).join('/'),
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
kind: Kind.ARGUMENT,
|
|
25
|
+
name: {
|
|
26
|
+
kind: Kind.NAME,
|
|
27
|
+
value: 'import',
|
|
28
|
+
},
|
|
29
|
+
value: {
|
|
30
|
+
kind: Kind.LIST,
|
|
31
|
+
values: link.imports.map(im => ({
|
|
32
|
+
kind: Kind.STRING,
|
|
33
|
+
value: im.name,
|
|
34
|
+
})),
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function parseLinkUrl(urlString) {
|
|
41
|
+
const url = new URL(urlString);
|
|
42
|
+
const parts = url.pathname.split('/').filter(Boolean);
|
|
43
|
+
const len = parts.length;
|
|
44
|
+
if (!len) {
|
|
45
|
+
return { name: null, version: null, identity: url.origin };
|
|
46
|
+
}
|
|
47
|
+
const last = parts[len - 1];
|
|
48
|
+
const secondLast = parts[len - 2];
|
|
49
|
+
const potentiallyNameAndVersion = typeof secondLast === 'string';
|
|
50
|
+
if (potentiallyNameAndVersion) {
|
|
51
|
+
return {
|
|
52
|
+
name: secondLast,
|
|
53
|
+
version: last,
|
|
54
|
+
identity: url.origin +
|
|
55
|
+
'/' +
|
|
56
|
+
parts
|
|
57
|
+
.slice(0, len - 2)
|
|
58
|
+
.concat(secondLast)
|
|
59
|
+
.join('/'),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (/^v\d+/i.test(last)) {
|
|
63
|
+
return {
|
|
64
|
+
name: null,
|
|
65
|
+
version: last,
|
|
66
|
+
identity: url.origin,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
name: last,
|
|
71
|
+
version: null,
|
|
72
|
+
identity: url.origin +
|
|
73
|
+
'/' +
|
|
74
|
+
parts
|
|
75
|
+
.slice(0, len - 2)
|
|
76
|
+
.concat(last)
|
|
77
|
+
.join('/'),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function parseLinkImport(importString) {
|
|
81
|
+
try {
|
|
82
|
+
const bindings = JSON5.parse(importString);
|
|
83
|
+
if (!Array.isArray(bindings)) {
|
|
84
|
+
throw new Error(`Expected an array`);
|
|
85
|
+
}
|
|
86
|
+
return bindings.map(binding => {
|
|
87
|
+
if (typeof binding === 'string') {
|
|
88
|
+
return {
|
|
89
|
+
kind: binding.startsWith('@') ? 'directive' : 'type',
|
|
90
|
+
name: binding,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (typeof binding === 'object' && binding.name) {
|
|
94
|
+
const nameKind = binding.name.startsWith('@') ? 'directive' : 'type';
|
|
95
|
+
if (!binding.as) {
|
|
96
|
+
return {
|
|
97
|
+
kind: nameKind,
|
|
98
|
+
name: binding.name,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const aliasKind = binding.as.startsWith('@') ? 'directive' : 'type';
|
|
102
|
+
if (nameKind !== aliasKind) {
|
|
103
|
+
throw new Error(`${binding.name} and ${binding.as} must be of the same kind`);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
kind: nameKind,
|
|
107
|
+
name: binding.name,
|
|
108
|
+
alias: binding.as,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
throw new Error(`Syntax`);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
throw new Error(`Invalid import binding: ${importString}: ${String(error)}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export function mergeLinks(links) {
|
|
119
|
+
const groupByIdentity = new Map();
|
|
120
|
+
for (const link of links) {
|
|
121
|
+
const existing = groupByIdentity.get(link.identity);
|
|
122
|
+
if (!existing) {
|
|
123
|
+
const importedDirectives = link.imports.filter(im => im.kind === 'directive');
|
|
124
|
+
if (importedDirectives.length === 0) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
groupByIdentity.set(link.identity, {
|
|
128
|
+
name: link.name,
|
|
129
|
+
highestVersion: link.version ?? '',
|
|
130
|
+
imports: link.imports.filter(im => im.kind === 'directive'),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
if (link.version &&
|
|
135
|
+
parseFloat(link.version.replace('v', '')) >
|
|
136
|
+
parseFloat(existing.highestVersion.replace('v', ''))) {
|
|
137
|
+
existing.highestVersion = link.version;
|
|
138
|
+
}
|
|
139
|
+
for (const im of link.imports) {
|
|
140
|
+
if (im.kind === 'type') {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const hasImport = existing.imports.some(existingIm => existingIm.kind === im.kind && existingIm.name === im.name);
|
|
144
|
+
if (!hasImport) {
|
|
145
|
+
existing.imports.push(im);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (link.name) {
|
|
149
|
+
existing.name = link.name;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return Array.from(groupByIdentity.entries()).map(([identity, link]) => ({
|
|
154
|
+
identity,
|
|
155
|
+
version: link.highestVersion,
|
|
156
|
+
imports: Array.from(link.imports).map(link => ({ kind: link.kind, name: link.name })),
|
|
157
|
+
name: link.name,
|
|
158
|
+
}));
|
|
159
|
+
}
|
|
160
|
+
export function parseLink(urlString, importString) {
|
|
161
|
+
const spec = parseLinkUrl(urlString);
|
|
162
|
+
return {
|
|
163
|
+
name: spec.name,
|
|
164
|
+
version: spec.version,
|
|
165
|
+
identity: spec.identity,
|
|
166
|
+
imports: parseLinkImport(importString),
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
export function parseLinkDirective(directive) {
|
|
170
|
+
const urlArg = directive.arguments?.find(isUrlArgument);
|
|
171
|
+
if (!urlArg) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
const importArg = directive.arguments?.find(isImportArgument);
|
|
175
|
+
const spec = parseLinkUrl(urlArg?.value.value);
|
|
176
|
+
return {
|
|
177
|
+
name: spec.name,
|
|
178
|
+
version: spec.version,
|
|
179
|
+
identity: spec.identity,
|
|
180
|
+
imports: parseLinkImport(importArg ? print(importArg.value) : '[]'),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function isUrlArgument(arg) {
|
|
184
|
+
return arg.name.value === 'url' && arg.value.kind === Kind.STRING;
|
|
185
|
+
}
|
|
186
|
+
function isImportArgument(arg) {
|
|
187
|
+
return arg.name.value === 'import' && arg.value.kind === Kind.LIST;
|
|
188
|
+
}
|
|
189
|
+
export const sdl = `
|
|
190
|
+
directive @link(
|
|
191
|
+
url: String
|
|
192
|
+
as: String
|
|
193
|
+
for: link__Purpose
|
|
194
|
+
import: [link__Import]
|
|
195
|
+
) repeatable on SCHEMA
|
|
196
|
+
|
|
197
|
+
scalar link__Import
|
|
198
|
+
|
|
199
|
+
enum link__Purpose {
|
|
200
|
+
"""
|
|
201
|
+
\`SECURITY\` features provide metadata necessary to securely resolve fields.
|
|
202
|
+
"""
|
|
203
|
+
SECURITY
|
|
204
|
+
|
|
205
|
+
"""
|
|
206
|
+
\`EXECUTION\` features provide metadata necessary for operation execution.
|
|
207
|
+
"""
|
|
208
|
+
EXECUTION
|
|
209
|
+
}
|
|
210
|
+
`;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { parse } from 'graphql';
|
|
2
|
+
import { isDirectiveDefinition } from '../graphql/helpers.js';
|
|
3
|
+
export const sdl = `
|
|
4
|
+
directive @tag(
|
|
5
|
+
name: String!
|
|
6
|
+
) repeatable on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | SCHEMA
|
|
7
|
+
`;
|
|
8
|
+
export const typeDefs = parse(sdl);
|
|
9
|
+
export const directive = typeDefs.definitions.filter(isDirectiveDefinition)[0];
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { GraphQLError, Kind, parse, } from 'graphql';
|
|
2
|
+
import { print } from '../graphql/printer.js';
|
|
3
|
+
export function validateDirectiveAgainstOriginal(providedDirectiveNode, directiveName, context) {
|
|
4
|
+
if (!context.isAvailableFederationDirective(directiveName, providedDirectiveNode)) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const isFederationV2 = context.satisfiesVersionRange('>= v2.0');
|
|
8
|
+
const federationDirective = context
|
|
9
|
+
.getKnownFederationDirectives()
|
|
10
|
+
.find(d => context.isAvailableFederationDirective(directiveName, d));
|
|
11
|
+
if (!federationDirective) {
|
|
12
|
+
throw new Error(`Federation directive @${directiveName} not found`);
|
|
13
|
+
}
|
|
14
|
+
const errors = [];
|
|
15
|
+
const original = {
|
|
16
|
+
args: new Map(federationDirective.arguments?.map(arg => [arg.name.value, arg])),
|
|
17
|
+
locations: federationDirective.locations.map(loc => loc.value),
|
|
18
|
+
};
|
|
19
|
+
const provided = {
|
|
20
|
+
args: new Map(providedDirectiveNode.arguments?.map(arg => [arg.name.value, arg])),
|
|
21
|
+
locations: providedDirectiveNode.locations.map(loc => loc.value),
|
|
22
|
+
};
|
|
23
|
+
for (const [argName, argDef] of original.args.entries()) {
|
|
24
|
+
const providedArgNode = provided.args.get(argName);
|
|
25
|
+
if (isNonNullTypeNode(argDef.type) && !providedArgNode) {
|
|
26
|
+
errors.push(new GraphQLError(`Invalid definition for directive "@${directiveName}": missing required argument "${argName}"`, {
|
|
27
|
+
nodes: providedDirectiveNode,
|
|
28
|
+
extensions: { code: 'DIRECTIVE_DEFINITION_INVALID' },
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
if (providedArgNode) {
|
|
32
|
+
const expectedType = print(argDef.type);
|
|
33
|
+
const providedType = print(providedArgNode.type);
|
|
34
|
+
if (expectedType !== providedType) {
|
|
35
|
+
const isNonNullableString = providedType === 'String!';
|
|
36
|
+
const allowedFieldSetTypes = isFederationV2
|
|
37
|
+
? ['FieldSet!', 'federation__FieldSet!', '_FieldSet!']
|
|
38
|
+
: ['_FieldSet!', 'String'];
|
|
39
|
+
const fieldSetTypesInSpec = isFederationV2
|
|
40
|
+
? ['FieldSet!', 'federation__FieldSet!', '_FieldSet!']
|
|
41
|
+
: ['_FieldSet!', 'FieldSet!', 'String'];
|
|
42
|
+
const expectsFieldSet = fieldSetTypesInSpec.includes(expectedType);
|
|
43
|
+
if (!isNonNullableString && expectsFieldSet) {
|
|
44
|
+
const isOneOfExpected = allowedFieldSetTypes.includes(providedType);
|
|
45
|
+
if (!isOneOfExpected) {
|
|
46
|
+
errors.push(new GraphQLError(`Invalid definition for directive "@${directiveName}": argument "${argName}" should have type "${expectedType}" but found type "${providedType}"`, {
|
|
47
|
+
nodes: providedDirectiveNode,
|
|
48
|
+
extensions: { code: 'DIRECTIVE_DEFINITION_INVALID' },
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (expectedType === 'Boolean' && argDef.defaultValue?.kind === Kind.BOOLEAN) {
|
|
54
|
+
let providedValue = null;
|
|
55
|
+
if (providedArgNode.defaultValue) {
|
|
56
|
+
if (providedArgNode.defaultValue.kind !== Kind.BOOLEAN) {
|
|
57
|
+
throw new Error('Expected a Boolean');
|
|
58
|
+
}
|
|
59
|
+
providedValue = providedArgNode.defaultValue.value;
|
|
60
|
+
}
|
|
61
|
+
if (argDef.defaultValue?.value !== providedValue) {
|
|
62
|
+
errors.push(new GraphQLError(`Invalid definition for directive "@${directiveName}": argument "${argName}" should have default value ${argDef.defaultValue ? 'true' : 'false'} but found default value ${providedValue ?? 'null'}`, {
|
|
63
|
+
nodes: providedDirectiveNode,
|
|
64
|
+
extensions: { code: 'DIRECTIVE_DEFINITION_INVALID' },
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const locationIntersection = provided.locations.filter(loc => original.locations.includes(loc));
|
|
71
|
+
if (!locationIntersection.length) {
|
|
72
|
+
errors.push(new GraphQLError(`Invalid definition for directive "@${directiveName}": "@${directiveName}" should have locations ${Array.from(original.locations).join(', ')}, but found (non-subset) ${Array.from(provided.locations).join(', ')}`, {
|
|
73
|
+
nodes: providedDirectiveNode,
|
|
74
|
+
extensions: { code: 'DIRECTIVE_DEFINITION_INVALID' },
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
if (errors.length) {
|
|
78
|
+
for (const error of errors) {
|
|
79
|
+
context.reportError(error);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
context.markAsFederationDefinitionReplacement(providedDirectiveNode.name.value);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export function visitFields({ context, selectionSet, typeDefinition, interceptField, interceptArguments, interceptUnknownField, interceptDirective, interceptInterfaceType, interceptExternalField, interceptNonExternalField, }) {
|
|
87
|
+
for (const selection of selectionSet.selections) {
|
|
88
|
+
if (selection.kind === Kind.FRAGMENT_SPREAD) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (selection.kind === Kind.INLINE_FRAGMENT) {
|
|
92
|
+
if (!selection.typeCondition) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const interfaceName = selection.typeCondition.name.value;
|
|
96
|
+
const interfaceDefinition = context.getSubgraphObjectOrInterfaceTypes().get(interfaceName);
|
|
97
|
+
if (!interfaceDefinition) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
visitFields({
|
|
101
|
+
context,
|
|
102
|
+
selectionSet: selection.selectionSet,
|
|
103
|
+
typeDefinition: interfaceDefinition,
|
|
104
|
+
interceptArguments,
|
|
105
|
+
interceptUnknownField,
|
|
106
|
+
interceptInterfaceType,
|
|
107
|
+
});
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
const selectionFieldDef = selection.name.value === '__typename'
|
|
111
|
+
? {
|
|
112
|
+
kind: Kind.FIELD_DEFINITION,
|
|
113
|
+
name: {
|
|
114
|
+
kind: Kind.NAME,
|
|
115
|
+
value: '__typename',
|
|
116
|
+
},
|
|
117
|
+
type: {
|
|
118
|
+
kind: Kind.NAMED_TYPE,
|
|
119
|
+
name: {
|
|
120
|
+
kind: Kind.NAME,
|
|
121
|
+
value: 'String',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
}
|
|
125
|
+
: typeDefinition.fields?.find(field => field.name.value === selection.name.value);
|
|
126
|
+
if (!selectionFieldDef) {
|
|
127
|
+
if (interceptUnknownField) {
|
|
128
|
+
interceptUnknownField({
|
|
129
|
+
typeDefinition,
|
|
130
|
+
fieldName: selection.name.value,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
if (interceptDirective && selection.directives?.length) {
|
|
136
|
+
for (const directive of selection.directives) {
|
|
137
|
+
interceptDirective({
|
|
138
|
+
directiveName: directive.name.value,
|
|
139
|
+
isKnown: context.getSubgraphDirectiveDefinitions().has(directive.name.value),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
context.markAsUsed('fields', typeDefinition.kind, typeDefinition.name.value, selectionFieldDef.name.value);
|
|
144
|
+
if (interceptField) {
|
|
145
|
+
interceptField({
|
|
146
|
+
typeDefinition,
|
|
147
|
+
fieldName: selection.name.value,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
if (selectionFieldDef.arguments?.length && interceptArguments) {
|
|
151
|
+
interceptArguments({
|
|
152
|
+
typeDefinition,
|
|
153
|
+
fieldName: selection.name.value,
|
|
154
|
+
});
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (interceptNonExternalField || interceptExternalField) {
|
|
158
|
+
const isExternal = selectionFieldDef.directives?.some(d => context.isAvailableFederationDirective('external', d));
|
|
159
|
+
const fieldName = selection.name.value;
|
|
160
|
+
const fieldDef = typeDefinition.fields?.find(field => field.name.value === fieldName);
|
|
161
|
+
if (!fieldDef) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
const namedType = namedTypeFromTypeNode(fieldDef.type);
|
|
165
|
+
const isLeaf = context.isLeafType(namedType.name.value);
|
|
166
|
+
if (isLeaf) {
|
|
167
|
+
if (isExternal && interceptExternalField) {
|
|
168
|
+
interceptExternalField({
|
|
169
|
+
typeDefinition,
|
|
170
|
+
fieldName,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
else if (!isExternal && interceptNonExternalField) {
|
|
174
|
+
interceptNonExternalField({
|
|
175
|
+
typeDefinition,
|
|
176
|
+
fieldName,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const outputType = namedTypeFromTypeNode(selectionFieldDef.type).name.value;
|
|
182
|
+
const innerTypeDef = context.getSubgraphObjectOrInterfaceTypes().get(outputType);
|
|
183
|
+
if (!innerTypeDef) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (interceptInterfaceType &&
|
|
187
|
+
(innerTypeDef.kind === Kind.INTERFACE_TYPE_DEFINITION ||
|
|
188
|
+
innerTypeDef.kind === Kind.INTERFACE_TYPE_EXTENSION)) {
|
|
189
|
+
interceptInterfaceType({
|
|
190
|
+
typeDefinition,
|
|
191
|
+
fieldName: selection.name.value,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
const innerSelection = selection.selectionSet;
|
|
195
|
+
if (!innerSelection) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
visitFields({
|
|
199
|
+
context,
|
|
200
|
+
selectionSet: innerSelection,
|
|
201
|
+
typeDefinition: innerTypeDef,
|
|
202
|
+
interceptArguments,
|
|
203
|
+
interceptUnknownField,
|
|
204
|
+
interceptInterfaceType,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
export function getFieldsArgument(directiveNode) {
|
|
209
|
+
const fieldsArg = directiveNode.arguments?.find(arg => arg.name.value === 'fields');
|
|
210
|
+
if (!fieldsArg) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
return fieldsArg;
|
|
214
|
+
}
|
|
215
|
+
export function parseFields(fields) {
|
|
216
|
+
const parsed = parse(fields.trim().startsWith(`{`) ? `query ${fields}` : `query { ${fields} }`).definitions.find(d => d.kind === Kind.OPERATION_DEFINITION);
|
|
217
|
+
return parsed?.selectionSet;
|
|
218
|
+
}
|
|
219
|
+
export function namedTypeFromTypeNode(type) {
|
|
220
|
+
if (type.kind === Kind.NAMED_TYPE) {
|
|
221
|
+
return type;
|
|
222
|
+
}
|
|
223
|
+
if (type.kind === Kind.LIST_TYPE) {
|
|
224
|
+
return namedTypeFromTypeNode(type.type);
|
|
225
|
+
}
|
|
226
|
+
if (type.kind === Kind.NON_NULL_TYPE) {
|
|
227
|
+
return namedTypeFromTypeNode(type.type);
|
|
228
|
+
}
|
|
229
|
+
throw new Error('Unknown type node: ' + type);
|
|
230
|
+
}
|
|
231
|
+
export function isDirectiveDefinitionNode(node) {
|
|
232
|
+
return node.kind === Kind.DIRECTIVE_DEFINITION;
|
|
233
|
+
}
|
|
234
|
+
export function printOutputType(type) {
|
|
235
|
+
if (type.kind === Kind.NAMED_TYPE) {
|
|
236
|
+
return type.name.value;
|
|
237
|
+
}
|
|
238
|
+
if (type.kind === Kind.LIST_TYPE) {
|
|
239
|
+
return `[${printOutputType(type.type)}]`;
|
|
240
|
+
}
|
|
241
|
+
return `${printOutputType(type.type)}!`;
|
|
242
|
+
}
|
|
243
|
+
function isNonNullTypeNode(node) {
|
|
244
|
+
return node.kind === Kind.NON_NULL_TYPE;
|
|
245
|
+
}
|