@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,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KnownTypeNamesRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function isTypeDefinitionOrExtensionNode(node) {
|
|
6
|
+
return (0, graphql_1.isTypeDefinitionNode)(node) || (0, graphql_1.isTypeExtensionNode)(node);
|
|
7
|
+
}
|
|
8
|
+
function KnownTypeNamesRule(context) {
|
|
9
|
+
const { definitions } = context.getDocument();
|
|
10
|
+
const typeNames = new Set(definitions.filter(isTypeDefinitionOrExtensionNode).map(def => def.name.value));
|
|
11
|
+
return {
|
|
12
|
+
NamedType(node, _1, parent, _2, ancestors) {
|
|
13
|
+
const typeName = node.name.value;
|
|
14
|
+
if (!typeNames.has(typeName)) {
|
|
15
|
+
const definitionNode = ancestors[2] ?? parent;
|
|
16
|
+
const isSDL = definitionNode != null && isSDLNode(definitionNode);
|
|
17
|
+
if (isSDL && standardTypeNames.has(typeName)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
context.reportError(new graphql_1.GraphQLError(`Unknown type ${typeName}`, {
|
|
21
|
+
nodes: node,
|
|
22
|
+
extensions: {
|
|
23
|
+
code: 'INVALID_GRAPHQL',
|
|
24
|
+
},
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.KnownTypeNamesRule = KnownTypeNamesRule;
|
|
31
|
+
const standardTypeNames = new Set([...graphql_1.specifiedScalarTypes].map(type => type.name));
|
|
32
|
+
function isSDLNode(value) {
|
|
33
|
+
return 'kind' in value && ((0, graphql_1.isTypeSystemDefinitionNode)(value) || (0, graphql_1.isTypeSystemExtensionNode)(value));
|
|
34
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoneSchemaDefinitionRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function LoneSchemaDefinitionRule(context) {
|
|
6
|
+
let schemaDefinitionsCount = 0;
|
|
7
|
+
return {
|
|
8
|
+
SchemaDefinition() {
|
|
9
|
+
if (schemaDefinitionsCount > 0) {
|
|
10
|
+
context.reportError(new graphql_1.GraphQLError('Must provide only one schema definition.', {
|
|
11
|
+
extensions: {
|
|
12
|
+
code: 'INVALID_GRAPHQL',
|
|
13
|
+
},
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
++schemaDefinitionsCount;
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.LoneSchemaDefinitionRule = LoneSchemaDefinitionRule;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProvidedArgumentsOnDirectivesRule = 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 ProvidedArgumentsOnDirectivesRule(context) {
|
|
8
|
+
return {
|
|
9
|
+
Directive: {
|
|
10
|
+
leave(directiveNode, _k, _p, _pp, ancestors) {
|
|
11
|
+
const directiveName = directiveNode.name.value;
|
|
12
|
+
const directiveDefinition = context.getKnownDirectiveDefinition(directiveName);
|
|
13
|
+
if (!directiveDefinition) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const args = directiveNode.arguments;
|
|
17
|
+
if (args && directiveDefinition.arguments) {
|
|
18
|
+
const coordinate = context.getSchemaCoordinate(ancestors);
|
|
19
|
+
for (const arg of args) {
|
|
20
|
+
const argDefinition = directiveDefinition.arguments.find(a => a.name.value === arg.name.value);
|
|
21
|
+
if (argDefinition && arg.value) {
|
|
22
|
+
if (argDefinition.type.kind === graphql_1.Kind.NON_NULL_TYPE && arg.value.kind === graphql_1.Kind.NULL) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const printedType = printTypeNode(argDefinition.type, context);
|
|
26
|
+
const printedValue = printValueNode(arg.value);
|
|
27
|
+
if (!printedType) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (printedType !== 'Any' && printedType !== printedValue) {
|
|
31
|
+
const namedType = (0, helpers_js_1.namedTypeFromTypeNode)(argDefinition.type);
|
|
32
|
+
const typeName = namedType.name.value;
|
|
33
|
+
if (printedValue === 'Int' && typeName === 'Float') {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
context.reportError(new graphql_1.GraphQLError(`Invalid value for "@${directiveName}(${arg.name.value}:)" of type "${(0, printer_js_1.print)(argDefinition.type)}" in application of "@${directiveName}" to "${coordinate}".`, {
|
|
37
|
+
nodes: arg,
|
|
38
|
+
extensions: {
|
|
39
|
+
code: 'INVALID_GRAPHQL',
|
|
40
|
+
},
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
exports.ProvidedArgumentsOnDirectivesRule = ProvidedArgumentsOnDirectivesRule;
|
|
51
|
+
function printValueNode(valueNode) {
|
|
52
|
+
switch (valueNode.kind) {
|
|
53
|
+
case graphql_1.Kind.LIST:
|
|
54
|
+
if (!valueNode.values.length) {
|
|
55
|
+
return '[]';
|
|
56
|
+
}
|
|
57
|
+
return printValueNode(valueNode.values[0]);
|
|
58
|
+
case graphql_1.Kind.ENUM:
|
|
59
|
+
return 'Enum';
|
|
60
|
+
case graphql_1.Kind.NULL:
|
|
61
|
+
return 'Null';
|
|
62
|
+
case graphql_1.Kind.INT:
|
|
63
|
+
return 'Int';
|
|
64
|
+
case graphql_1.Kind.FLOAT:
|
|
65
|
+
return 'Float';
|
|
66
|
+
case graphql_1.Kind.STRING:
|
|
67
|
+
return 'String';
|
|
68
|
+
case graphql_1.Kind.BOOLEAN:
|
|
69
|
+
return 'Boolean';
|
|
70
|
+
case graphql_1.Kind.OBJECT:
|
|
71
|
+
return 'Object';
|
|
72
|
+
}
|
|
73
|
+
throw new Error(`Unknown value node kind: ${valueNode}`);
|
|
74
|
+
}
|
|
75
|
+
function printTypeNode(typeNode, context) {
|
|
76
|
+
if (typeNode.kind === graphql_1.Kind.NAMED_TYPE) {
|
|
77
|
+
const def = context.getKnownTypeDefinition(typeNode.name.value);
|
|
78
|
+
if (!def) {
|
|
79
|
+
const specifiedScalar = graphql_1.specifiedScalarTypes.find(s => s.name === typeNode.name.value);
|
|
80
|
+
if (specifiedScalar) {
|
|
81
|
+
return specifiedScalar.name;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
switch (def.kind) {
|
|
86
|
+
case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
|
|
87
|
+
case graphql_1.Kind.SCALAR_TYPE_EXTENSION:
|
|
88
|
+
return 'Any';
|
|
89
|
+
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
90
|
+
case graphql_1.Kind.ENUM_TYPE_EXTENSION:
|
|
91
|
+
return 'Enum';
|
|
92
|
+
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
93
|
+
case graphql_1.Kind.INPUT_OBJECT_TYPE_EXTENSION:
|
|
94
|
+
case graphql_1.Kind.OBJECT_TYPE_DEFINITION:
|
|
95
|
+
case graphql_1.Kind.OBJECT_TYPE_EXTENSION:
|
|
96
|
+
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
|
|
97
|
+
case graphql_1.Kind.INTERFACE_TYPE_EXTENSION:
|
|
98
|
+
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
99
|
+
case graphql_1.Kind.UNION_TYPE_EXTENSION:
|
|
100
|
+
return 'Object';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return printTypeNode(typeNode.type, context);
|
|
104
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProvidedRequiredArgumentsOnDirectivesRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
const printer_js_1 = require("../../../graphql/printer.js");
|
|
6
|
+
function ProvidedRequiredArgumentsOnDirectivesRule(context) {
|
|
7
|
+
const requiredArgsMap = Object.create(null);
|
|
8
|
+
const astDefinitions = context.getDocument().definitions;
|
|
9
|
+
for (const def of astDefinitions) {
|
|
10
|
+
if (def.kind === graphql_1.Kind.DIRECTIVE_DEFINITION) {
|
|
11
|
+
const argNodes = def.arguments ?? [];
|
|
12
|
+
const requiredArgs = argNodes.filter(isRequiredArgumentNode);
|
|
13
|
+
requiredArgsMap[def.name.value] = {};
|
|
14
|
+
for (const requiredArg of requiredArgs) {
|
|
15
|
+
requiredArgsMap[def.name.value][requiredArg.name.value] = requiredArg;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
Directive: {
|
|
21
|
+
leave(directiveNode) {
|
|
22
|
+
const directiveName = directiveNode.name.value;
|
|
23
|
+
const requiredArgs = requiredArgsMap[directiveName];
|
|
24
|
+
if (requiredArgs) {
|
|
25
|
+
const argNodes = directiveNode.arguments ?? [];
|
|
26
|
+
const argNodeMap = new Set(argNodes.map(arg => arg.name.value));
|
|
27
|
+
for (const [argName, argDef] of Object.entries(requiredArgs)) {
|
|
28
|
+
if (!argNodeMap.has(argName)) {
|
|
29
|
+
const argType = (0, printer_js_1.print)(argDef.type);
|
|
30
|
+
context.reportError(new graphql_1.GraphQLError(`Directive "@${directiveName}" argument "${argName}" of type "${argType}" is required, but it was not provided.`, {
|
|
31
|
+
nodes: directiveNode,
|
|
32
|
+
extensions: {
|
|
33
|
+
code: 'INVALID_GRAPHQL',
|
|
34
|
+
},
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
exports.ProvidedRequiredArgumentsOnDirectivesRule = ProvidedRequiredArgumentsOnDirectivesRule;
|
|
44
|
+
function isRequiredArgumentNode(arg) {
|
|
45
|
+
return arg.type.kind === graphql_1.Kind.NON_NULL_TYPE && arg.defaultValue == null;
|
|
46
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryRootTypeInaccessibleRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function QueryRootTypeInaccessibleRule(context) {
|
|
6
|
+
let rootTypeName = 'Query';
|
|
7
|
+
return {
|
|
8
|
+
SchemaDefinition(node) {
|
|
9
|
+
const nonQueryType = node.operationTypes?.find(operationType => operationType.operation === graphql_1.OperationTypeNode.QUERY &&
|
|
10
|
+
operationType.type.name.value !== 'Query');
|
|
11
|
+
if (nonQueryType) {
|
|
12
|
+
rootTypeName = nonQueryType.type.name.value;
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
SchemaExtension(node) {
|
|
16
|
+
const nonQueryType = node.operationTypes?.find(operationType => operationType.operation === graphql_1.OperationTypeNode.QUERY &&
|
|
17
|
+
operationType.type.name.value !== 'Query');
|
|
18
|
+
if (nonQueryType) {
|
|
19
|
+
rootTypeName = nonQueryType.type.name.value;
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
ObjectTypeDefinition(node) {
|
|
23
|
+
const name = node.name.value;
|
|
24
|
+
if (name !== rootTypeName) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (node.directives?.some(directive => context.isAvailableFederationDirective('inaccessible', directive))) {
|
|
28
|
+
context.reportError(new graphql_1.GraphQLError(`Type "Query" is @inaccessible but is the root query type, which must be in the API schema.`, { nodes: node, extensions: { code: 'QUERY_ROOT_TYPE_INACCESSIBLE' } }));
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.QueryRootTypeInaccessibleRule = QueryRootTypeInaccessibleRule;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReservedSubgraphNameRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function ReservedSubgraphNameRule(context) {
|
|
6
|
+
if (context.getSubgraphName() === '_') {
|
|
7
|
+
context.reportError(new graphql_1.GraphQLError(`Invalid name _ for a subgraph: this name is reserved`, {
|
|
8
|
+
extensions: {
|
|
9
|
+
code: 'INVALID_SUBGRAPH_NAME',
|
|
10
|
+
},
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
exports.ReservedSubgraphNameRule = ReservedSubgraphNameRule;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RootTypeUsedRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function findDefaultRootTypes(definitions) {
|
|
6
|
+
const foundRootTypes = {
|
|
7
|
+
query: null,
|
|
8
|
+
mutation: null,
|
|
9
|
+
subscription: null,
|
|
10
|
+
};
|
|
11
|
+
const found = new Set();
|
|
12
|
+
for (const definition of definitions) {
|
|
13
|
+
if (found.size === 3) {
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
if ((0, graphql_1.isTypeDefinitionNode)(definition)) {
|
|
17
|
+
if (definition.name.value === 'Query') {
|
|
18
|
+
foundRootTypes.query = 'Query';
|
|
19
|
+
found.add(graphql_1.OperationTypeNode.QUERY);
|
|
20
|
+
}
|
|
21
|
+
else if (definition.name.value === 'Mutation') {
|
|
22
|
+
foundRootTypes.mutation = 'Mutation';
|
|
23
|
+
found.add(graphql_1.OperationTypeNode.MUTATION);
|
|
24
|
+
}
|
|
25
|
+
else if (definition.name.value === 'Subscription') {
|
|
26
|
+
foundRootTypes.subscription = 'Subscription';
|
|
27
|
+
found.add(graphql_1.OperationTypeNode.SUBSCRIPTION);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return foundRootTypes;
|
|
32
|
+
}
|
|
33
|
+
function validateSchemaNode(node, definitions, context) {
|
|
34
|
+
const definedDefaultRootTypes = findDefaultRootTypes(definitions);
|
|
35
|
+
for (const operationType of node.operationTypes ?? []) {
|
|
36
|
+
const defaultRootType = definedDefaultRootTypes[operationType.operation];
|
|
37
|
+
const usedRootTypeName = operationType.type.name.value;
|
|
38
|
+
if (defaultRootType && defaultRootType !== usedRootTypeName) {
|
|
39
|
+
context.reportError(new graphql_1.GraphQLError(`The schema has a type named "${defaultRootType}" but it is not set as the ${operationType.operation} root type ("${usedRootTypeName}" is instead): this is not supported by federation. If a root type does not use its default name, there should be no other type with that default name.`, {
|
|
40
|
+
nodes: node,
|
|
41
|
+
extensions: {
|
|
42
|
+
code: `ROOT_${operationType.operation.toUpperCase()}_USED`,
|
|
43
|
+
},
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function RootTypeUsedRule(context) {
|
|
49
|
+
const { definitions } = context.getDocument();
|
|
50
|
+
return {
|
|
51
|
+
SchemaDefinition(node) {
|
|
52
|
+
validateSchemaNode(node, definitions, context);
|
|
53
|
+
},
|
|
54
|
+
SchemaExtension(node) {
|
|
55
|
+
validateSchemaNode(node, definitions, context);
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
exports.RootTypeUsedRule = RootTypeUsedRule;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UniqueArgumentDefinitionNamesRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function UniqueArgumentDefinitionNamesRule(context) {
|
|
6
|
+
return {
|
|
7
|
+
DirectiveDefinition(directiveNode) {
|
|
8
|
+
const argumentNodes = directiveNode.arguments ?? [];
|
|
9
|
+
return checkArgUniqueness(`@${directiveNode.name.value}`, argumentNodes);
|
|
10
|
+
},
|
|
11
|
+
InterfaceTypeDefinition: checkArgUniquenessPerField,
|
|
12
|
+
InterfaceTypeExtension: checkArgUniquenessPerField,
|
|
13
|
+
ObjectTypeDefinition: checkArgUniquenessPerField,
|
|
14
|
+
ObjectTypeExtension: checkArgUniquenessPerField,
|
|
15
|
+
};
|
|
16
|
+
function checkArgUniquenessPerField(typeNode) {
|
|
17
|
+
const typeName = typeNode.name.value;
|
|
18
|
+
const fieldNodes = typeNode.fields ?? [];
|
|
19
|
+
for (const fieldDef of fieldNodes) {
|
|
20
|
+
const fieldName = fieldDef.name.value;
|
|
21
|
+
const argumentNodes = fieldDef.arguments ?? [];
|
|
22
|
+
checkArgUniqueness(`${typeName}.${fieldName}`, argumentNodes);
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
function checkArgUniqueness(parentName, argumentNodes) {
|
|
27
|
+
const visitedArgumentNames = new Set();
|
|
28
|
+
for (const argDef of argumentNodes) {
|
|
29
|
+
if (visitedArgumentNames.has(argDef.name.value)) {
|
|
30
|
+
context.reportError(new graphql_1.GraphQLError(`Argument "${parentName}(${argDef.name.value}:)" can only be defined once.`, {
|
|
31
|
+
extensions: {
|
|
32
|
+
code: 'INVALID_GRAPHQL',
|
|
33
|
+
},
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
visitedArgumentNames.add(argDef.name.value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.UniqueArgumentDefinitionNamesRule = UniqueArgumentDefinitionNamesRule;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UniqueArgumentNamesRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function UniqueArgumentNamesRule(context) {
|
|
6
|
+
return {
|
|
7
|
+
Field: checkArgUniqueness,
|
|
8
|
+
Directive: checkArgUniqueness,
|
|
9
|
+
};
|
|
10
|
+
function checkArgUniqueness(parentNode) {
|
|
11
|
+
const argumentNodes = parentNode.arguments ?? [];
|
|
12
|
+
const seenArgs = new Set();
|
|
13
|
+
for (const argumentNode of argumentNodes) {
|
|
14
|
+
if (seenArgs.has(argumentNode.name.value)) {
|
|
15
|
+
context.reportError(new graphql_1.GraphQLError(`There can be only one argument named "${argumentNode.name.value}".`, {
|
|
16
|
+
extensions: {
|
|
17
|
+
code: 'INVALID_GRAPHQL',
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
seenArgs.add(argumentNode.name.value);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.UniqueArgumentNamesRule = UniqueArgumentNamesRule;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UniqueDirectiveNamesRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function UniqueDirectiveNamesRule(context) {
|
|
6
|
+
const knownDirectiveNameNodes = new Set();
|
|
7
|
+
return {
|
|
8
|
+
DirectiveDefinition(node) {
|
|
9
|
+
const directiveName = node.name.value;
|
|
10
|
+
const existingNameNode = knownDirectiveNameNodes.has(directiveName);
|
|
11
|
+
if (existingNameNode) {
|
|
12
|
+
context.reportError(new graphql_1.GraphQLError(`There can be only one directive named "@${directiveName}".`, {
|
|
13
|
+
extensions: {
|
|
14
|
+
code: 'INVALID_GRAPHQL',
|
|
15
|
+
},
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
knownDirectiveNameNodes.add(directiveName);
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.UniqueDirectiveNamesRule = UniqueDirectiveNamesRule;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UniqueDirectivesPerLocationRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function UniqueDirectivesPerLocationRule(context) {
|
|
6
|
+
const uniqueDirectiveMap = new Map();
|
|
7
|
+
const astDefinitions = context.getDocument().definitions;
|
|
8
|
+
for (const def of astDefinitions) {
|
|
9
|
+
if (def.kind === graphql_1.Kind.DIRECTIVE_DEFINITION) {
|
|
10
|
+
uniqueDirectiveMap.set(def.name.value, !def.repeatable);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const schemaDirectives = new Set();
|
|
14
|
+
const typeDirectivesMap = new Map();
|
|
15
|
+
return {
|
|
16
|
+
enter(node) {
|
|
17
|
+
if (!('directives' in node) || !node.directives) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
let seenDirectives;
|
|
21
|
+
if (node.kind === graphql_1.Kind.SCHEMA_DEFINITION || node.kind === graphql_1.Kind.SCHEMA_EXTENSION) {
|
|
22
|
+
seenDirectives = schemaDirectives;
|
|
23
|
+
}
|
|
24
|
+
else if ((0, graphql_1.isTypeDefinitionNode)(node) || (0, graphql_1.isTypeExtensionNode)(node)) {
|
|
25
|
+
const typeName = node.name.value;
|
|
26
|
+
if (!typeDirectivesMap.has(typeName)) {
|
|
27
|
+
typeDirectivesMap.set(typeName, new Set());
|
|
28
|
+
}
|
|
29
|
+
seenDirectives = typeDirectivesMap.get(typeName);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
seenDirectives = new Set();
|
|
33
|
+
}
|
|
34
|
+
for (const directive of node.directives) {
|
|
35
|
+
const directiveName = directive.name.value;
|
|
36
|
+
if (uniqueDirectiveMap.get(directiveName)) {
|
|
37
|
+
if (seenDirectives.has(directiveName)) {
|
|
38
|
+
context.reportError(new graphql_1.GraphQLError(`The directive "@${directiveName}" can only be used once at this location.`, {
|
|
39
|
+
extensions: {
|
|
40
|
+
code: 'INVALID_GRAPHQL',
|
|
41
|
+
},
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
seenDirectives.add(directive.name.value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
exports.UniqueDirectivesPerLocationRule = UniqueDirectivesPerLocationRule;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UniqueEnumValueNamesRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function UniqueEnumValueNamesRule(context) {
|
|
6
|
+
const knownValueNames = new Map();
|
|
7
|
+
return {
|
|
8
|
+
EnumTypeDefinition: checkValueUniqueness,
|
|
9
|
+
EnumTypeExtension: checkValueUniqueness,
|
|
10
|
+
};
|
|
11
|
+
function checkValueUniqueness(node) {
|
|
12
|
+
const typeName = node.name.value;
|
|
13
|
+
if (!knownValueNames.has(typeName)) {
|
|
14
|
+
knownValueNames.set(typeName, new Set());
|
|
15
|
+
}
|
|
16
|
+
const valueNodes = node.values ?? [];
|
|
17
|
+
const valueNames = knownValueNames.get(typeName);
|
|
18
|
+
for (const valueDef of valueNodes) {
|
|
19
|
+
const valueName = valueDef.name.value;
|
|
20
|
+
if (valueNames.has(valueName)) {
|
|
21
|
+
context.reportError(new graphql_1.GraphQLError(`Enum value "${typeName}.${valueName}" can only be defined once.`, {
|
|
22
|
+
extensions: {
|
|
23
|
+
code: 'INVALID_GRAPHQL',
|
|
24
|
+
},
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
valueNames.add(valueName);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.UniqueEnumValueNamesRule = UniqueEnumValueNamesRule;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UniqueFieldDefinitionNamesRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function UniqueFieldDefinitionNamesRule(context) {
|
|
6
|
+
const knownFieldNames = new Map();
|
|
7
|
+
return {
|
|
8
|
+
InputObjectTypeDefinition: checkFieldUniqueness,
|
|
9
|
+
InputObjectTypeExtension: checkFieldUniqueness,
|
|
10
|
+
InterfaceTypeDefinition: checkFieldUniqueness,
|
|
11
|
+
InterfaceTypeExtension: checkFieldUniqueness,
|
|
12
|
+
ObjectTypeDefinition: checkFieldUniqueness,
|
|
13
|
+
ObjectTypeExtension: checkFieldUniqueness,
|
|
14
|
+
};
|
|
15
|
+
function checkFieldUniqueness(node) {
|
|
16
|
+
const typeName = node.name.value;
|
|
17
|
+
if (!knownFieldNames.has(typeName)) {
|
|
18
|
+
knownFieldNames.set(typeName, new Set());
|
|
19
|
+
}
|
|
20
|
+
const fieldNodes = node.fields ?? [];
|
|
21
|
+
const fieldNames = knownFieldNames.get(typeName);
|
|
22
|
+
for (const fieldDef of fieldNodes) {
|
|
23
|
+
const fieldName = fieldDef.name.value;
|
|
24
|
+
if (fieldNames.has(fieldName)) {
|
|
25
|
+
context.reportError(new graphql_1.GraphQLError(`Field "${typeName}.${fieldName}" can only be defined once.`, {
|
|
26
|
+
extensions: {
|
|
27
|
+
code: 'INVALID_GRAPHQL',
|
|
28
|
+
},
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
fieldNames.add(fieldName);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.UniqueFieldDefinitionNamesRule = UniqueFieldDefinitionNamesRule;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UniqueInputFieldNamesRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function UniqueInputFieldNamesRule(context) {
|
|
6
|
+
const knownNameStack = [];
|
|
7
|
+
let knownNames = new Set();
|
|
8
|
+
return {
|
|
9
|
+
ObjectValue: {
|
|
10
|
+
enter() {
|
|
11
|
+
knownNameStack.push(knownNames);
|
|
12
|
+
knownNames = new Set();
|
|
13
|
+
},
|
|
14
|
+
leave() {
|
|
15
|
+
const prevKnownNames = knownNameStack.pop();
|
|
16
|
+
if (!prevKnownNames) {
|
|
17
|
+
throw new Error('Assertion failed: nothing else in the stack');
|
|
18
|
+
}
|
|
19
|
+
knownNames = prevKnownNames;
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
ObjectField(node) {
|
|
23
|
+
const fieldName = node.name.value;
|
|
24
|
+
if (knownNames.has(fieldName)) {
|
|
25
|
+
context.reportError(new graphql_1.GraphQLError(`There can be only one input field named "${fieldName}".`, {
|
|
26
|
+
extensions: {
|
|
27
|
+
code: 'INVALID_GRAPHQL',
|
|
28
|
+
},
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
knownNames.add(fieldName);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.UniqueInputFieldNamesRule = UniqueInputFieldNamesRule;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UniqueOperationTypesRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function UniqueOperationTypesRule(context) {
|
|
6
|
+
const definedOperationTypes = new Set();
|
|
7
|
+
return {
|
|
8
|
+
SchemaDefinition: checkOperationTypes,
|
|
9
|
+
SchemaExtension: checkOperationTypes,
|
|
10
|
+
};
|
|
11
|
+
function checkOperationTypes(node) {
|
|
12
|
+
const operationTypesNodes = node.operationTypes || [];
|
|
13
|
+
for (const operationType of operationTypesNodes) {
|
|
14
|
+
const operation = operationType.operation;
|
|
15
|
+
const alreadyDefinedOperationType = definedOperationTypes.has(operation);
|
|
16
|
+
if (alreadyDefinedOperationType) {
|
|
17
|
+
context.reportError(new graphql_1.GraphQLError(`There can be only one ${operation} type in schema.`, {
|
|
18
|
+
extensions: {
|
|
19
|
+
code: 'INVALID_GRAPHQL',
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
definedOperationTypes.add(operation);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.UniqueOperationTypesRule = UniqueOperationTypesRule;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UniqueTypeNamesRule = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function UniqueTypeNamesRule(context) {
|
|
6
|
+
const knownTypeNames = new Set();
|
|
7
|
+
return {
|
|
8
|
+
ScalarTypeDefinition: checkTypeName,
|
|
9
|
+
ObjectTypeDefinition: checkTypeName,
|
|
10
|
+
InterfaceTypeDefinition: checkTypeName,
|
|
11
|
+
UnionTypeDefinition: checkTypeName,
|
|
12
|
+
EnumTypeDefinition: checkTypeName,
|
|
13
|
+
InputObjectTypeDefinition: checkTypeName,
|
|
14
|
+
};
|
|
15
|
+
function checkTypeName(node) {
|
|
16
|
+
const typeName = node.name.value;
|
|
17
|
+
if (knownTypeNames.has(typeName)) {
|
|
18
|
+
context.reportError(new graphql_1.GraphQLError(`There can be only one type named "${typeName}".`, {
|
|
19
|
+
extensions: {
|
|
20
|
+
code: 'INVALID_GRAPHQL',
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
knownTypeNames.add(typeName);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.UniqueTypeNamesRule = UniqueTypeNamesRule;
|