graphql 17.0.0-beta.2 → 17.0.0
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/README.md +3 -5
- package/__dev__/diagnostics.d.mts +1 -0
- package/__dev__/diagnostics.d.ts +1 -0
- package/__dev__/diagnostics.js +3 -0
- package/__dev__/diagnostics.mjs +3 -0
- package/diagnostics.d.mts +307 -0
- package/diagnostics.d.ts +307 -0
- package/diagnostics.js +75 -0
- package/diagnostics.js.map +1 -0
- package/diagnostics.mjs +70 -0
- package/diagnostics.mjs.map +1 -0
- package/error/GraphQLError.d.mts +3 -1
- package/error/GraphQLError.d.ts +3 -1
- package/error/GraphQLError.js +3 -3
- package/error/GraphQLError.js.map +1 -1
- package/error/GraphQLError.mjs +3 -3
- package/error/GraphQLError.mjs.map +1 -1
- package/error/locatedError.d.mts +1 -3
- package/error/locatedError.d.ts +1 -3
- package/error/locatedError.js.map +1 -1
- package/error/locatedError.mjs.map +1 -1
- package/execution/ExecutionArgs.d.mts +6 -0
- package/execution/ExecutionArgs.d.ts +6 -0
- package/execution/ExecutionArgs.js.map +1 -1
- package/execution/ExecutionArgs.mjs.map +1 -1
- package/execution/Executor.d.mts +19 -1
- package/execution/Executor.d.ts +19 -1
- package/execution/Executor.js +49 -4
- package/execution/Executor.js.map +1 -1
- package/execution/Executor.mjs +49 -4
- package/execution/Executor.mjs.map +1 -1
- package/execution/execute.d.mts +65 -44
- package/execution/execute.d.ts +65 -44
- package/execution/execute.js +73 -4
- package/execution/execute.js.map +1 -1
- package/execution/execute.mjs +73 -4
- package/execution/execute.mjs.map +1 -1
- package/execution/values.d.mts +17 -17
- package/execution/values.d.ts +17 -17
- package/execution/values.js.map +1 -1
- package/execution/values.mjs.map +1 -1
- package/index.d.mts +1 -0
- package/index.d.ts +1 -0
- package/index.js.map +1 -1
- package/index.mjs.map +1 -1
- package/language/parser.d.mts +20 -30
- package/language/parser.d.ts +20 -30
- package/language/parser.js +9 -9
- package/language/parser.js.map +1 -1
- package/language/parser.mjs +9 -9
- package/language/parser.mjs.map +1 -1
- package/language/predicates.d.mts +5 -1
- package/language/predicates.d.ts +5 -1
- package/language/predicates.js.map +1 -1
- package/language/predicates.mjs.map +1 -1
- package/language/source.d.mts +4 -5
- package/language/source.d.ts +4 -5
- package/language/source.js.map +1 -1
- package/language/source.mjs.map +1 -1
- package/language/visitor.d.mts +10 -2
- package/language/visitor.d.ts +10 -2
- package/language/visitor.js.map +1 -1
- package/language/visitor.mjs.map +1 -1
- package/package.json +2 -2
- package/type/definition.d.mts +96 -64
- package/type/definition.d.ts +96 -64
- package/type/definition.js.map +1 -1
- package/type/definition.mjs.map +1 -1
- package/type/directives.d.mts +3 -3
- package/type/directives.d.ts +3 -3
- package/type/directives.js.map +1 -1
- package/type/directives.mjs.map +1 -1
- package/type/schema.d.mts +4 -8
- package/type/schema.d.ts +4 -8
- package/type/schema.js.map +1 -1
- package/type/schema.mjs.map +1 -1
- package/type/validate.js +101 -30
- package/type/validate.js.map +1 -1
- package/type/validate.mjs +101 -30
- package/type/validate.mjs.map +1 -1
- package/utilities/TypeInfo.d.mts +1 -1
- package/utilities/TypeInfo.d.ts +1 -1
- package/utilities/TypeInfo.js.map +1 -1
- package/utilities/TypeInfo.mjs.map +1 -1
- package/utilities/buildASTSchema.d.mts +0 -1
- package/utilities/buildASTSchema.d.ts +0 -1
- package/utilities/buildASTSchema.js +0 -1
- package/utilities/buildASTSchema.js.map +1 -1
- package/utilities/buildASTSchema.mjs +0 -1
- package/utilities/buildASTSchema.mjs.map +1 -1
- package/utilities/buildClientSchema.d.mts +5 -1
- package/utilities/buildClientSchema.d.ts +5 -1
- package/utilities/buildClientSchema.js.map +1 -1
- package/utilities/buildClientSchema.mjs.map +1 -1
- package/utilities/coerceInputValue.d.mts +7 -6
- package/utilities/coerceInputValue.d.ts +7 -6
- package/utilities/coerceInputValue.js.map +1 -1
- package/utilities/coerceInputValue.mjs.map +1 -1
- package/utilities/concatAST.d.mts +4 -1
- package/utilities/concatAST.d.ts +4 -1
- package/utilities/concatAST.js.map +1 -1
- package/utilities/concatAST.mjs.map +1 -1
- package/utilities/extendSchema.d.mts +3 -3
- package/utilities/extendSchema.d.ts +3 -3
- package/utilities/extendSchema.js +5 -1
- package/utilities/extendSchema.js.map +1 -1
- package/utilities/extendSchema.mjs +5 -1
- package/utilities/extendSchema.mjs.map +1 -1
- package/utilities/introspectionFromSchema.d.mts +6 -2
- package/utilities/introspectionFromSchema.d.ts +6 -2
- package/utilities/introspectionFromSchema.js.map +1 -1
- package/utilities/introspectionFromSchema.mjs.map +1 -1
- package/utilities/lexicographicSortSchema.d.mts +5 -1
- package/utilities/lexicographicSortSchema.d.ts +5 -1
- package/utilities/lexicographicSortSchema.js.map +1 -1
- package/utilities/lexicographicSortSchema.mjs.map +1 -1
- package/utilities/printSchema.d.mts +5 -1
- package/utilities/printSchema.d.ts +5 -1
- package/utilities/printSchema.js.map +1 -1
- package/utilities/printSchema.mjs.map +1 -1
- package/utilities/replaceVariables.d.mts +4 -8
- package/utilities/replaceVariables.d.ts +4 -8
- package/utilities/replaceVariables.js.map +1 -1
- package/utilities/replaceVariables.mjs.map +1 -1
- package/utilities/stripIgnoredCharacters.d.mts +2 -2
- package/utilities/stripIgnoredCharacters.d.ts +2 -2
- package/utilities/stripIgnoredCharacters.js.map +1 -1
- package/utilities/stripIgnoredCharacters.mjs.map +1 -1
- package/utilities/typeComparators.d.mts +1 -5
- package/utilities/typeComparators.d.ts +1 -5
- package/utilities/typeComparators.js.map +1 -1
- package/utilities/typeComparators.mjs.map +1 -1
- package/utilities/validateInputValue.d.mts +10 -8
- package/utilities/validateInputValue.d.ts +10 -8
- package/utilities/validateInputValue.js.map +1 -1
- package/utilities/validateInputValue.mjs.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.mts +4 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.ts +4 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.js +70 -17
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.js.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs +70 -17
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.d.mts +1 -1
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.d.ts +1 -1
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js +90 -21
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs +91 -22
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs.map +1 -1
- package/validation/rules/ExecutableDefinitionsRule.d.mts +6 -2
- package/validation/rules/ExecutableDefinitionsRule.d.ts +6 -2
- package/validation/rules/ExecutableDefinitionsRule.js.map +1 -1
- package/validation/rules/ExecutableDefinitionsRule.mjs.map +1 -1
- package/validation/rules/FieldsOnCorrectTypeRule.d.mts +3 -1
- package/validation/rules/FieldsOnCorrectTypeRule.d.ts +3 -1
- package/validation/rules/FieldsOnCorrectTypeRule.js.map +1 -1
- package/validation/rules/FieldsOnCorrectTypeRule.mjs.map +1 -1
- package/validation/rules/FragmentsOnCompositeTypesRule.d.mts +6 -2
- package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +6 -2
- package/validation/rules/FragmentsOnCompositeTypesRule.js.map +1 -1
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs.map +1 -1
- package/validation/rules/KnownArgumentNamesRule.d.mts +3 -1
- package/validation/rules/KnownArgumentNamesRule.d.ts +3 -1
- package/validation/rules/KnownArgumentNamesRule.js.map +1 -1
- package/validation/rules/KnownArgumentNamesRule.mjs.map +1 -1
- package/validation/rules/KnownDirectivesRule.js +2 -1
- package/validation/rules/KnownDirectivesRule.js.map +1 -1
- package/validation/rules/KnownDirectivesRule.mjs +2 -1
- package/validation/rules/KnownDirectivesRule.mjs.map +1 -1
- package/validation/rules/KnownFragmentNamesRule.d.mts +3 -1
- package/validation/rules/KnownFragmentNamesRule.d.ts +3 -1
- package/validation/rules/KnownFragmentNamesRule.js.map +1 -1
- package/validation/rules/KnownFragmentNamesRule.mjs.map +1 -1
- package/validation/rules/LoneAnonymousOperationRule.d.mts +6 -2
- package/validation/rules/LoneAnonymousOperationRule.d.ts +6 -2
- package/validation/rules/LoneAnonymousOperationRule.js.map +1 -1
- package/validation/rules/LoneAnonymousOperationRule.mjs.map +1 -1
- package/validation/rules/MaxIntrospectionDepthRule.d.mts +6 -2
- package/validation/rules/MaxIntrospectionDepthRule.d.ts +6 -2
- package/validation/rules/MaxIntrospectionDepthRule.js.map +1 -1
- package/validation/rules/MaxIntrospectionDepthRule.mjs.map +1 -1
- package/validation/rules/NoUndefinedVariablesRule.d.mts +3 -1
- package/validation/rules/NoUndefinedVariablesRule.d.ts +3 -1
- package/validation/rules/NoUndefinedVariablesRule.js.map +1 -1
- package/validation/rules/NoUndefinedVariablesRule.mjs.map +1 -1
- package/validation/rules/NoUnusedFragmentsRule.d.mts +3 -1
- package/validation/rules/NoUnusedFragmentsRule.d.ts +3 -1
- package/validation/rules/NoUnusedFragmentsRule.js.map +1 -1
- package/validation/rules/NoUnusedFragmentsRule.mjs.map +1 -1
- package/validation/rules/NoUnusedVariablesRule.d.mts +3 -1
- package/validation/rules/NoUnusedVariablesRule.d.ts +3 -1
- package/validation/rules/NoUnusedVariablesRule.js.map +1 -1
- package/validation/rules/NoUnusedVariablesRule.mjs.map +1 -1
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.mts +6 -2
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +6 -2
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js.map +1 -1
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs.map +1 -1
- package/validation/rules/PossibleFragmentSpreadsRule.d.mts +6 -2
- package/validation/rules/PossibleFragmentSpreadsRule.d.ts +6 -2
- package/validation/rules/PossibleFragmentSpreadsRule.js.map +1 -1
- package/validation/rules/PossibleFragmentSpreadsRule.mjs.map +1 -1
- package/validation/rules/ProvidedRequiredArgumentsRule.d.mts +6 -2
- package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +6 -2
- package/validation/rules/ProvidedRequiredArgumentsRule.js.map +1 -1
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs.map +1 -1
- package/validation/rules/SingleFieldSubscriptionsRule.d.mts +6 -2
- package/validation/rules/SingleFieldSubscriptionsRule.d.ts +6 -2
- package/validation/rules/SingleFieldSubscriptionsRule.js.map +1 -1
- package/validation/rules/SingleFieldSubscriptionsRule.mjs.map +1 -1
- package/validation/rules/UniqueArgumentNamesRule.d.mts +3 -1
- package/validation/rules/UniqueArgumentNamesRule.d.ts +3 -1
- package/validation/rules/UniqueArgumentNamesRule.js.map +1 -1
- package/validation/rules/UniqueArgumentNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueDirectivesPerLocationRule.d.mts +6 -2
- package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +6 -2
- package/validation/rules/UniqueDirectivesPerLocationRule.js.map +1 -1
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs.map +1 -1
- package/validation/rules/UniqueFragmentNamesRule.d.mts +3 -1
- package/validation/rules/UniqueFragmentNamesRule.d.ts +3 -1
- package/validation/rules/UniqueFragmentNamesRule.js.map +1 -1
- package/validation/rules/UniqueFragmentNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueInputFieldNamesRule.d.mts +6 -2
- package/validation/rules/UniqueInputFieldNamesRule.d.ts +6 -2
- package/validation/rules/UniqueInputFieldNamesRule.js.map +1 -1
- package/validation/rules/UniqueInputFieldNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueOperationNamesRule.d.mts +3 -1
- package/validation/rules/UniqueOperationNamesRule.d.ts +3 -1
- package/validation/rules/UniqueOperationNamesRule.js.map +1 -1
- package/validation/rules/UniqueOperationNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueVariableNamesRule.d.mts +3 -1
- package/validation/rules/UniqueVariableNamesRule.d.ts +3 -1
- package/validation/rules/UniqueVariableNamesRule.js.map +1 -1
- package/validation/rules/UniqueVariableNamesRule.mjs.map +1 -1
- package/validation/rules/ValuesOfCorrectTypeRule.d.mts +3 -1
- package/validation/rules/ValuesOfCorrectTypeRule.d.ts +3 -1
- package/validation/rules/ValuesOfCorrectTypeRule.js.map +1 -1
- package/validation/rules/ValuesOfCorrectTypeRule.mjs.map +1 -1
- package/validation/rules/VariablesAreInputTypesRule.d.mts +6 -2
- package/validation/rules/VariablesAreInputTypesRule.d.ts +6 -2
- package/validation/rules/VariablesAreInputTypesRule.js.map +1 -1
- package/validation/rules/VariablesAreInputTypesRule.mjs.map +1 -1
- package/validation/rules/VariablesInAllowedPositionRule.d.mts +6 -2
- package/validation/rules/VariablesInAllowedPositionRule.d.ts +6 -2
- package/validation/rules/VariablesInAllowedPositionRule.js.map +1 -1
- package/validation/rules/VariablesInAllowedPositionRule.mjs.map +1 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.d.mts +3 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +3 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.js.map +1 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs.map +1 -1
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.mts +6 -2
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +6 -2
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js.map +1 -1
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs.map +1 -1
- package/validation/validate.d.mts +3 -6
- package/validation/validate.d.ts +3 -6
- package/validation/validate.js +6 -0
- package/validation/validate.js.map +1 -1
- package/validation/validate.mjs +6 -0
- package/validation/validate.mjs.map +1 -1
- package/version.js +2 -2
- package/version.js.map +1 -1
- package/version.mjs +2 -2
- package/version.mjs.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SingleFieldSubscriptionsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/SingleFieldSubscriptionsRule.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAG3D,OAAO,EAAE,IAAI,EAAE,iCAAgC;AAO/C,OAAO,EAAE,aAAa,EAAE,0CAAyC;AAKjE,SAAS,OAAO,CAAC,gBAAkC;IACjD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;
|
|
1
|
+
{"version":3,"file":"SingleFieldSubscriptionsRule.js","sourceRoot":"","sources":["../../../src/validation/rules/SingleFieldSubscriptionsRule.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAG3D,OAAO,EAAE,IAAI,EAAE,iCAAgC;AAO/C,OAAO,EAAE,aAAa,EAAE,0CAAyC;AAKjE,SAAS,OAAO,CAAC,gBAAkC;IACjD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AA8CD,MAAM,UAAU,4BAA4B,CAC1C,OAA0B;IAE1B,OAAO;QACL,mBAAmB,CAAC,IAA6B;YAC/C,IAAI,IAAI,CAAC,SAAS,KAAK,cAAc,EAAE,CAAC;gBACtC,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;gBACnC,MAAM,gBAAgB,GAAG,MAAM,CAAC,mBAAmB,EAAE,CAAC;gBACtD,IAAI,gBAAgB,EAAE,CAAC;oBACrB,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;oBACzD,MAAM,cAAc,GAAmB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;oBAC3D,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;oBACvC,MAAM,SAAS,GAA4B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;oBAC/D,KAAK,MAAM,UAAU,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;wBAC9C,IAAI,UAAU,CAAC,IAAI,KAAK,IAAI,CAAC,mBAAmB,EAAE,CAAC;4BACjD,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,UAAU,EAAE,CAAC;wBACpD,CAAC;oBACH,CAAC;oBACD,MAAM,EAAE,eAAe,EAAE,2BAA2B,EAAE,GACpD,aAAa,CACX,MAAM,EACN,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,IAAI,CAAC,YAAY,EACjB,OAAO,CAAC,eAAe,EACvB,IAAI,CACL,CAAC;oBACJ,IAAI,2BAA2B,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBAC3C,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,aAAa,IAAI,IAAI;4BACnB,CAAC,CAAC,iBAAiB,aAAa,iFAAiF;4BACjH,CAAC,CAAC,kGAAkG,EACtG,EAAE,KAAK,EAAE,2BAA2B,EAAE,CACvC,CACF,CAAC;wBACF,OAAO;oBACT,CAAC;oBACD,IAAI,eAAe,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;wBAC7B,MAAM,iBAAiB,GAAG,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC;wBACxD,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;wBAC1D,MAAM,oBAAoB,GAAG,sBAAsB,CAAC,OAAO,CACzD,CAAC,gBAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAChD,CAAC;wBACF,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,aAAa,IAAI,IAAI;4BACnB,CAAC,CAAC,iBAAiB,aAAa,yCAAyC;4BACzE,CAAC,CAAC,8DAA8D,EAClE,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAChC,CACF,CAAC;oBACJ,CAAC;oBACD,KAAK,MAAM,gBAAgB,IAAI,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC;wBACxD,MAAM,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;wBAC1D,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;4BAC/B,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,aAAa,IAAI,IAAI;gCACnB,CAAC,CAAC,iBAAiB,aAAa,qDAAqD;gCACrF,CAAC,CAAC,0EAA0E,EAC9E,EAAE,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAAE,CACrC,CACF,CAAC;wBACJ,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @category Validation Rules */\n\nimport type { ObjMap } from '../../jsutils/ObjMap.ts';\n\nimport { GraphQLError } from '../../error/GraphQLError.ts';\n\nimport type { FieldNode, OperationDefinitionNode } from '../../language/ast.ts';\nimport { Kind } from '../../language/kinds.ts';\nimport type { ASTVisitor } from '../../language/visitor.ts';\n\nimport type {\n FieldDetailsList,\n FragmentDetails,\n} from '../../execution/collectFields.ts';\nimport { collectFields } from '../../execution/collectFields.ts';\nimport type { VariableValues } from '../../execution/values.ts';\n\nimport type { ValidationContext } from '../ValidationContext.ts';\n\nfunction toNodes(fieldDetailsList: FieldDetailsList): ReadonlyArray<FieldNode> {\n return fieldDetailsList.map((fieldDetails) => fieldDetails.node);\n}\n\n/**\n * Subscriptions must only include a non-introspection field.\n *\n * A GraphQL subscription is valid only if it contains a single root field and\n * that root field is not an introspection field.\n *\n * See https://spec.graphql.org/draft/#sec-Single-root-field\n * @param context - The validation context used while checking the document.\n * @returns A visitor that reports validation errors for this rule.\n * @example\n * ```ts\n * import { buildSchema, parse, validate } from 'graphql';\n * import { SingleFieldSubscriptionsRule } from 'graphql/validation';\n *\n * const schema = buildSchema(`\n * type Query {\n * name: String\n * }\n *\n * type Subscription {\n * a: String\n * b: String\n * }\n * `);\n *\n * const invalidDocument = parse(`\n * subscription { a b }\n * `);\n * const invalidErrors = validate(schema, invalidDocument, [\n * SingleFieldSubscriptionsRule,\n * ]);\n *\n * invalidErrors.length; // => 1\n *\n * const validDocument = parse(`\n * subscription { a }\n * `);\n * const validErrors = validate(schema, validDocument, [\n * SingleFieldSubscriptionsRule,\n * ]);\n *\n * validErrors; // => []\n * ```\n */\nexport function SingleFieldSubscriptionsRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n OperationDefinition(node: OperationDefinitionNode) {\n if (node.operation === 'subscription') {\n const schema = context.getSchema();\n const subscriptionType = schema.getSubscriptionType();\n if (subscriptionType) {\n const operationName = node.name ? node.name.value : null;\n const variableValues: VariableValues = Object.create(null);\n const document = context.getDocument();\n const fragments: ObjMap<FragmentDetails> = Object.create(null);\n for (const definition of document.definitions) {\n if (definition.kind === Kind.FRAGMENT_DEFINITION) {\n fragments[definition.name.value] = { definition };\n }\n }\n const { groupedFieldSet, forbiddenDirectiveInstances } =\n collectFields(\n schema,\n fragments,\n variableValues,\n subscriptionType,\n node.selectionSet,\n context.hideSuggestions,\n true,\n );\n if (forbiddenDirectiveInstances.length > 0) {\n context.reportError(\n new GraphQLError(\n operationName != null\n ? `Subscription \"${operationName}\" must not use \\`@skip\\` or \\`@include\\` directives in the top level selection.`\n : 'Anonymous Subscription must not use `@skip` or `@include` directives in the top level selection.',\n { nodes: forbiddenDirectiveInstances },\n ),\n );\n return;\n }\n if (groupedFieldSet.size > 1) {\n const fieldDetailsLists = [...groupedFieldSet.values()];\n const extraFieldDetailsLists = fieldDetailsLists.slice(1);\n const extraFieldSelections = extraFieldDetailsLists.flatMap(\n (fieldDetailsList) => toNodes(fieldDetailsList),\n );\n context.reportError(\n new GraphQLError(\n operationName != null\n ? `Subscription \"${operationName}\" must select only one top level field.`\n : 'Anonymous Subscription must select only one top level field.',\n { nodes: extraFieldSelections },\n ),\n );\n }\n for (const fieldDetailsList of groupedFieldSet.values()) {\n const fieldName = toNodes(fieldDetailsList)[0].name.value;\n if (fieldName.startsWith('__')) {\n context.reportError(\n new GraphQLError(\n operationName != null\n ? `Subscription \"${operationName}\" must not select an introspection top level field.`\n : 'Anonymous Subscription must not select an introspection top level field.',\n { nodes: toNodes(fieldDetailsList) },\n ),\n );\n }\n }\n }\n }\n },\n };\n}\n"]}
|
|
@@ -24,7 +24,9 @@ import type { ASTValidationContext } from "../ValidationContext.mjs";
|
|
|
24
24
|
* const invalidDocument = parse(`
|
|
25
25
|
* { field(arg: "1", arg: "2") }
|
|
26
26
|
* `);
|
|
27
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
28
|
+
* UniqueArgumentNamesRule,
|
|
29
|
+
* ]);
|
|
28
30
|
*
|
|
29
31
|
* invalidErrors.length; // => 1
|
|
30
32
|
*
|
|
@@ -24,7 +24,9 @@ import type { ASTValidationContext } from "../ValidationContext.js";
|
|
|
24
24
|
* const invalidDocument = parse(`
|
|
25
25
|
* { field(arg: "1", arg: "2") }
|
|
26
26
|
* `);
|
|
27
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
28
|
+
* UniqueArgumentNamesRule,
|
|
29
|
+
* ]);
|
|
28
30
|
*
|
|
29
31
|
* invalidErrors.length; // => 1
|
|
30
32
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniqueArgumentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueArgumentNamesRule.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"UniqueArgumentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueArgumentNamesRule.ts"],"names":[],"mappings":";;AAgDA,0DA0BC;AAxED,yDAAmD;AAEnD,iEAA2D;AA4C3D,SAAgB,uBAAuB,CACrC,OAA6B;IAE7B,OAAO;QACL,KAAK,EAAE,kBAAkB;QACzB,SAAS,EAAE,kBAAkB;KAC9B,CAAC;IAEF,SAAS,kBAAkB,CAAC,UAE3B;QACC,MAAM,aAAa,GAAG,UAAU,CAAC,SAAS,IAAI,EAAE,CAAC;QAEjD,MAAM,QAAQ,GAAG,IAAA,oBAAO,EAAC,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEjE,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,QAAQ,EAAE,CAAC;YAC3C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxB,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,yCAAyC,OAAO,IAAI,EACpD,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC7C,CACF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/** @category Validation Rules */\n\nimport { groupBy } from '../../jsutils/groupBy.ts';\n\nimport { GraphQLError } from '../../error/GraphQLError.ts';\n\nimport type { ArgumentNode } from '../../language/ast.ts';\nimport type { ASTVisitor } from '../../language/visitor.ts';\n\nimport type { ASTValidationContext } from '../ValidationContext.ts';\n\n/**\n * Unique argument names\n *\n * A GraphQL field or directive is only valid if all supplied arguments are\n * uniquely named.\n *\n * See https://spec.graphql.org/draft/#sec-Argument-Names\n * @param context - The validation context used while checking the document.\n * @returns A visitor that reports validation errors for this rule.\n * @example\n * ```ts\n * import { buildSchema, parse, validate } from 'graphql';\n * import { UniqueArgumentNamesRule } from 'graphql/validation';\n *\n * const schema = buildSchema(`\n * type Query {\n * field(arg: String): String\n * }\n * `);\n *\n * const invalidDocument = parse(`\n * { field(arg: \"1\", arg: \"2\") }\n * `);\n * const invalidErrors = validate(schema, invalidDocument, [\n * UniqueArgumentNamesRule,\n * ]);\n *\n * invalidErrors.length; // => 1\n *\n * const validDocument = parse(`\n * { field(arg: \"1\") }\n * `);\n * const validErrors = validate(schema, validDocument, [UniqueArgumentNamesRule]);\n *\n * validErrors; // => []\n * ```\n */\nexport function UniqueArgumentNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n return {\n Field: checkArgUniqueness,\n Directive: checkArgUniqueness,\n };\n\n function checkArgUniqueness(parentNode: {\n arguments?: ReadonlyArray<ArgumentNode> | undefined;\n }) {\n const argumentNodes = parentNode.arguments ?? [];\n\n const seenArgs = groupBy(argumentNodes, (arg) => arg.name.value);\n\n for (const [argName, argNodes] of seenArgs) {\n if (argNodes.length > 1) {\n context.reportError(\n new GraphQLError(\n `There can be only one argument named \"${argName}\".`,\n { nodes: argNodes.map((node) => node.name) },\n ),\n );\n }\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniqueArgumentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueArgumentNamesRule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,kCAAiC;AAEnD,OAAO,EAAE,YAAY,EAAE,qCAAoC;
|
|
1
|
+
{"version":3,"file":"UniqueArgumentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueArgumentNamesRule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,kCAAiC;AAEnD,OAAO,EAAE,YAAY,EAAE,qCAAoC;AA4C3D,MAAM,UAAU,uBAAuB,CACrC,OAA6B;IAE7B,OAAO;QACL,KAAK,EAAE,kBAAkB;QACzB,SAAS,EAAE,kBAAkB;KAC9B,CAAC;IAEF,SAAS,kBAAkB,CAAC,UAE3B;QACC,MAAM,aAAa,GAAG,UAAU,CAAC,SAAS,IAAI,EAAE,CAAC;QAEjD,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEjE,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,QAAQ,EAAE,CAAC;YAC3C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxB,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,yCAAyC,OAAO,IAAI,EACpD,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC7C,CACF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/** @category Validation Rules */\n\nimport { groupBy } from '../../jsutils/groupBy.ts';\n\nimport { GraphQLError } from '../../error/GraphQLError.ts';\n\nimport type { ArgumentNode } from '../../language/ast.ts';\nimport type { ASTVisitor } from '../../language/visitor.ts';\n\nimport type { ASTValidationContext } from '../ValidationContext.ts';\n\n/**\n * Unique argument names\n *\n * A GraphQL field or directive is only valid if all supplied arguments are\n * uniquely named.\n *\n * See https://spec.graphql.org/draft/#sec-Argument-Names\n * @param context - The validation context used while checking the document.\n * @returns A visitor that reports validation errors for this rule.\n * @example\n * ```ts\n * import { buildSchema, parse, validate } from 'graphql';\n * import { UniqueArgumentNamesRule } from 'graphql/validation';\n *\n * const schema = buildSchema(`\n * type Query {\n * field(arg: String): String\n * }\n * `);\n *\n * const invalidDocument = parse(`\n * { field(arg: \"1\", arg: \"2\") }\n * `);\n * const invalidErrors = validate(schema, invalidDocument, [\n * UniqueArgumentNamesRule,\n * ]);\n *\n * invalidErrors.length; // => 1\n *\n * const validDocument = parse(`\n * { field(arg: \"1\") }\n * `);\n * const validErrors = validate(schema, validDocument, [UniqueArgumentNamesRule]);\n *\n * validErrors; // => []\n * ```\n */\nexport function UniqueArgumentNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n return {\n Field: checkArgUniqueness,\n Directive: checkArgUniqueness,\n };\n\n function checkArgUniqueness(parentNode: {\n arguments?: ReadonlyArray<ArgumentNode> | undefined;\n }) {\n const argumentNodes = parentNode.arguments ?? [];\n\n const seenArgs = groupBy(argumentNodes, (arg) => arg.name.value);\n\n for (const [argName, argNodes] of seenArgs) {\n if (argNodes.length > 1) {\n context.reportError(\n new GraphQLError(\n `There can be only one argument named \"${argName}\".`,\n { nodes: argNodes.map((node) => node.name) },\n ),\n );\n }\n }\n }\n}\n"]}
|
|
@@ -24,14 +24,18 @@ import type { SDLValidationContext, ValidationContext } from "../ValidationConte
|
|
|
24
24
|
* const invalidDocument = parse(`
|
|
25
25
|
* { name @include(if: true) @include(if: false) }
|
|
26
26
|
* `);
|
|
27
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
28
|
+
* UniqueDirectivesPerLocationRule,
|
|
29
|
+
* ]);
|
|
28
30
|
*
|
|
29
31
|
* invalidErrors.length; // => 1
|
|
30
32
|
*
|
|
31
33
|
* const validDocument = parse(`
|
|
32
34
|
* { name @include(if: true) }
|
|
33
35
|
* `);
|
|
34
|
-
* const validErrors = validate(schema, validDocument, [
|
|
36
|
+
* const validErrors = validate(schema, validDocument, [
|
|
37
|
+
* UniqueDirectivesPerLocationRule,
|
|
38
|
+
* ]);
|
|
35
39
|
*
|
|
36
40
|
* validErrors; // => []
|
|
37
41
|
* ```
|
|
@@ -24,14 +24,18 @@ import type { SDLValidationContext, ValidationContext } from "../ValidationConte
|
|
|
24
24
|
* const invalidDocument = parse(`
|
|
25
25
|
* { name @include(if: true) @include(if: false) }
|
|
26
26
|
* `);
|
|
27
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
28
|
+
* UniqueDirectivesPerLocationRule,
|
|
29
|
+
* ]);
|
|
28
30
|
*
|
|
29
31
|
* invalidErrors.length; // => 1
|
|
30
32
|
*
|
|
31
33
|
* const validDocument = parse(`
|
|
32
34
|
* { name @include(if: true) }
|
|
33
35
|
* `);
|
|
34
|
-
* const validErrors = validate(schema, validDocument, [
|
|
36
|
+
* const validErrors = validate(schema, validDocument, [
|
|
37
|
+
* UniqueDirectivesPerLocationRule,
|
|
38
|
+
* ]);
|
|
35
39
|
*
|
|
36
40
|
* validErrors; // => []
|
|
37
41
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniqueDirectivesPerLocationRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueDirectivesPerLocationRule.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"UniqueDirectivesPerLocationRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueDirectivesPerLocationRule.ts"],"names":[],"mappings":"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","sourcesContent":["/** @category Validation Rules */\n\nimport { GraphQLError } from '../../error/GraphQLError.ts';\n\nimport type { DirectiveNode } from '../../language/ast.ts';\nimport { Kind } from '../../language/kinds.ts';\nimport {\n isTypeDefinitionNode,\n isTypeExtensionNode,\n} from '../../language/predicates.ts';\nimport type { ASTVisitor } from '../../language/visitor.ts';\n\nimport { specifiedDirectives } from '../../type/directives.ts';\n\nimport type {\n SDLValidationContext,\n ValidationContext,\n} from '../ValidationContext.ts';\n\n/**\n * Unique directive names per location\n *\n * A GraphQL document is only valid if all non-repeatable directives at\n * a given location are uniquely named.\n *\n * See https://spec.graphql.org/draft/#sec-Directives-Are-Unique-Per-Location\n * @param context - The validation context used while checking the document.\n * @returns A visitor that reports validation errors for this rule.\n * @example\n * ```ts\n * import { buildSchema, parse, validate } from 'graphql';\n * import { UniqueDirectivesPerLocationRule } from 'graphql/validation';\n *\n * const schema = buildSchema(`\n * type Query {\n * name: String\n * }\n * `);\n *\n * const invalidDocument = parse(`\n * { name @include(if: true) @include(if: false) }\n * `);\n * const invalidErrors = validate(schema, invalidDocument, [\n * UniqueDirectivesPerLocationRule,\n * ]);\n *\n * invalidErrors.length; // => 1\n *\n * const validDocument = parse(`\n * { name @include(if: true) }\n * `);\n * const validErrors = validate(schema, validDocument, [\n * UniqueDirectivesPerLocationRule,\n * ]);\n *\n * validErrors; // => []\n * ```\n */\nexport function UniqueDirectivesPerLocationRule(\n context: ValidationContext | SDLValidationContext,\n): ASTVisitor {\n const uniqueDirectiveMap = new Map<string, boolean>();\n\n const schema = context.getSchema();\n const definedDirectives = schema\n ? schema.getDirectives()\n : specifiedDirectives;\n for (const directive of definedDirectives) {\n uniqueDirectiveMap.set(directive.name, !directive.isRepeatable);\n }\n\n const astDefinitions = context.getDocument().definitions;\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n uniqueDirectiveMap.set(def.name.value, !def.repeatable);\n }\n }\n\n const schemaDirectives = new Map<string, DirectiveNode>();\n const typeDirectivesMap = new Map<string, Map<string, DirectiveNode>>();\n const directiveDirectivesMap = new Map<string, Map<string, DirectiveNode>>();\n\n return {\n // Many different AST nodes may contain directives. Rather than listing\n // them all, just listen for entering any node, and check to see if it\n // defines any directives.\n enter(node) {\n if (!('directives' in node) || !node.directives) {\n return;\n }\n\n let seenDirectives;\n if (\n node.kind === Kind.SCHEMA_DEFINITION ||\n node.kind === Kind.SCHEMA_EXTENSION\n ) {\n seenDirectives = schemaDirectives;\n } else if (isTypeDefinitionNode(node) || isTypeExtensionNode(node)) {\n const typeName = node.name.value;\n seenDirectives = typeDirectivesMap.get(typeName);\n if (seenDirectives === undefined) {\n seenDirectives = new Map();\n typeDirectivesMap.set(typeName, seenDirectives);\n }\n } else if (\n node.kind === Kind.DIRECTIVE_DEFINITION ||\n node.kind === Kind.DIRECTIVE_EXTENSION\n ) {\n const directiveName = node.name.value;\n seenDirectives = directiveDirectivesMap.get(directiveName);\n if (seenDirectives === undefined) {\n seenDirectives = new Map();\n directiveDirectivesMap.set(directiveName, seenDirectives);\n }\n } else {\n seenDirectives = new Map();\n }\n\n for (const directive of node.directives) {\n const directiveName = directive.name.value;\n\n if (uniqueDirectiveMap.get(directiveName) === true) {\n const seenDirective = seenDirectives.get(directiveName);\n if (seenDirective != null) {\n context.reportError(\n new GraphQLError(\n `The directive \"@${directiveName}\" can only be used once at this location.`,\n { nodes: [seenDirective, directive] },\n ),\n );\n } else {\n seenDirectives.set(directiveName, directive);\n }\n }\n }\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniqueDirectivesPerLocationRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueDirectivesPerLocationRule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAG3D,OAAO,EAAE,IAAI,EAAE,iCAAgC;AAC/C,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,sCAAqC;AAGtC,OAAO,EAAE,mBAAmB,EAAE,kCAAiC;
|
|
1
|
+
{"version":3,"file":"UniqueDirectivesPerLocationRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueDirectivesPerLocationRule.ts"],"names":[],"mappings":"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","sourcesContent":["/** @category Validation Rules */\n\nimport { GraphQLError } from '../../error/GraphQLError.ts';\n\nimport type { DirectiveNode } from '../../language/ast.ts';\nimport { Kind } from '../../language/kinds.ts';\nimport {\n isTypeDefinitionNode,\n isTypeExtensionNode,\n} from '../../language/predicates.ts';\nimport type { ASTVisitor } from '../../language/visitor.ts';\n\nimport { specifiedDirectives } from '../../type/directives.ts';\n\nimport type {\n SDLValidationContext,\n ValidationContext,\n} from '../ValidationContext.ts';\n\n/**\n * Unique directive names per location\n *\n * A GraphQL document is only valid if all non-repeatable directives at\n * a given location are uniquely named.\n *\n * See https://spec.graphql.org/draft/#sec-Directives-Are-Unique-Per-Location\n * @param context - The validation context used while checking the document.\n * @returns A visitor that reports validation errors for this rule.\n * @example\n * ```ts\n * import { buildSchema, parse, validate } from 'graphql';\n * import { UniqueDirectivesPerLocationRule } from 'graphql/validation';\n *\n * const schema = buildSchema(`\n * type Query {\n * name: String\n * }\n * `);\n *\n * const invalidDocument = parse(`\n * { name @include(if: true) @include(if: false) }\n * `);\n * const invalidErrors = validate(schema, invalidDocument, [\n * UniqueDirectivesPerLocationRule,\n * ]);\n *\n * invalidErrors.length; // => 1\n *\n * const validDocument = parse(`\n * { name @include(if: true) }\n * `);\n * const validErrors = validate(schema, validDocument, [\n * UniqueDirectivesPerLocationRule,\n * ]);\n *\n * validErrors; // => []\n * ```\n */\nexport function UniqueDirectivesPerLocationRule(\n context: ValidationContext | SDLValidationContext,\n): ASTVisitor {\n const uniqueDirectiveMap = new Map<string, boolean>();\n\n const schema = context.getSchema();\n const definedDirectives = schema\n ? schema.getDirectives()\n : specifiedDirectives;\n for (const directive of definedDirectives) {\n uniqueDirectiveMap.set(directive.name, !directive.isRepeatable);\n }\n\n const astDefinitions = context.getDocument().definitions;\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n uniqueDirectiveMap.set(def.name.value, !def.repeatable);\n }\n }\n\n const schemaDirectives = new Map<string, DirectiveNode>();\n const typeDirectivesMap = new Map<string, Map<string, DirectiveNode>>();\n const directiveDirectivesMap = new Map<string, Map<string, DirectiveNode>>();\n\n return {\n // Many different AST nodes may contain directives. Rather than listing\n // them all, just listen for entering any node, and check to see if it\n // defines any directives.\n enter(node) {\n if (!('directives' in node) || !node.directives) {\n return;\n }\n\n let seenDirectives;\n if (\n node.kind === Kind.SCHEMA_DEFINITION ||\n node.kind === Kind.SCHEMA_EXTENSION\n ) {\n seenDirectives = schemaDirectives;\n } else if (isTypeDefinitionNode(node) || isTypeExtensionNode(node)) {\n const typeName = node.name.value;\n seenDirectives = typeDirectivesMap.get(typeName);\n if (seenDirectives === undefined) {\n seenDirectives = new Map();\n typeDirectivesMap.set(typeName, seenDirectives);\n }\n } else if (\n node.kind === Kind.DIRECTIVE_DEFINITION ||\n node.kind === Kind.DIRECTIVE_EXTENSION\n ) {\n const directiveName = node.name.value;\n seenDirectives = directiveDirectivesMap.get(directiveName);\n if (seenDirectives === undefined) {\n seenDirectives = new Map();\n directiveDirectivesMap.set(directiveName, seenDirectives);\n }\n } else {\n seenDirectives = new Map();\n }\n\n for (const directive of node.directives) {\n const directiveName = directive.name.value;\n\n if (uniqueDirectiveMap.get(directiveName) === true) {\n const seenDirective = seenDirectives.get(directiveName);\n if (seenDirective != null) {\n context.reportError(\n new GraphQLError(\n `The directive \"@${directiveName}\" can only be used once at this location.`,\n { nodes: [seenDirective, directive] },\n ),\n );\n } else {\n seenDirectives.set(directiveName, directive);\n }\n }\n }\n },\n };\n}\n"]}
|
|
@@ -23,7 +23,9 @@ import type { ASTValidationContext } from "../ValidationContext.mjs";
|
|
|
23
23
|
* const invalidDocument = parse(`
|
|
24
24
|
* fragment A on Query { name } fragment A on Query { name } query { ...A }
|
|
25
25
|
* `);
|
|
26
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
26
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* UniqueFragmentNamesRule,
|
|
28
|
+
* ]);
|
|
27
29
|
*
|
|
28
30
|
* invalidErrors.length; // => 1
|
|
29
31
|
*
|
|
@@ -23,7 +23,9 @@ import type { ASTValidationContext } from "../ValidationContext.js";
|
|
|
23
23
|
* const invalidDocument = parse(`
|
|
24
24
|
* fragment A on Query { name } fragment A on Query { name } query { ...A }
|
|
25
25
|
* `);
|
|
26
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
26
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* UniqueFragmentNamesRule,
|
|
28
|
+
* ]);
|
|
27
29
|
*
|
|
28
30
|
* invalidErrors.length; // => 1
|
|
29
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniqueFragmentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueFragmentNamesRule.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"UniqueFragmentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueFragmentNamesRule.ts"],"names":[],"mappings":";;AA6CA,0DAsBC;AAjED,iEAA2D;AA2C3D,SAAgB,uBAAuB,CACrC,OAA6B;IAE7B,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAoB,CAAC;IACvD,OAAO;QACL,mBAAmB,EAAE,GAAG,EAAE,CAAC,KAAK;QAChC,kBAAkB,CAAC,IAAI;YACrB,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YACrC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YAC/D,IAAI,iBAAiB,IAAI,IAAI,EAAE,CAAC;gBAC9B,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,yCAAyC,YAAY,IAAI,EACzD,EAAE,KAAK,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAC1C,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,kBAAkB,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAClD,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @category Validation Rules */\n\nimport { GraphQLError } from '../../error/GraphQLError.ts';\n\nimport type { NameNode } from '../../language/ast.ts';\nimport type { ASTVisitor } from '../../language/visitor.ts';\n\nimport type { ASTValidationContext } from '../ValidationContext.ts';\n\n/**\n * Unique fragment names\n *\n * A GraphQL document is only valid if all defined fragments have unique names.\n *\n * See https://spec.graphql.org/draft/#sec-Fragment-Name-Uniqueness\n * @param context - The validation context used while checking the document.\n * @returns A visitor that reports validation errors for this rule.\n * @example\n * ```ts\n * import { buildSchema, parse, validate } from 'graphql';\n * import { UniqueFragmentNamesRule } from 'graphql/validation';\n *\n * const schema = buildSchema(`\n * type Query {\n * name: String\n * }\n * `);\n *\n * const invalidDocument = parse(`\n * fragment A on Query { name } fragment A on Query { name } query { ...A }\n * `);\n * const invalidErrors = validate(schema, invalidDocument, [\n * UniqueFragmentNamesRule,\n * ]);\n *\n * invalidErrors.length; // => 1\n *\n * const validDocument = parse(`\n * fragment A on Query { name } query { ...A }\n * `);\n * const validErrors = validate(schema, validDocument, [UniqueFragmentNamesRule]);\n *\n * validErrors; // => []\n * ```\n */\nexport function UniqueFragmentNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n const knownFragmentNames = new Map<string, NameNode>();\n return {\n OperationDefinition: () => false,\n FragmentDefinition(node) {\n const fragmentName = node.name.value;\n const knownFragmentName = knownFragmentNames.get(fragmentName);\n if (knownFragmentName != null) {\n context.reportError(\n new GraphQLError(\n `There can be only one fragment named \"${fragmentName}\".`,\n { nodes: [knownFragmentName, node.name] },\n ),\n );\n } else {\n knownFragmentNames.set(fragmentName, node.name);\n }\n return false;\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniqueFragmentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueFragmentNamesRule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,qCAAoC;
|
|
1
|
+
{"version":3,"file":"UniqueFragmentNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueFragmentNamesRule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AA2C3D,MAAM,UAAU,uBAAuB,CACrC,OAA6B;IAE7B,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAoB,CAAC;IACvD,OAAO;QACL,mBAAmB,EAAE,GAAG,EAAE,CAAC,KAAK;QAChC,kBAAkB,CAAC,IAAI;YACrB,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YACrC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YAC/D,IAAI,iBAAiB,IAAI,IAAI,EAAE,CAAC;gBAC9B,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,yCAAyC,YAAY,IAAI,EACzD,EAAE,KAAK,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAC1C,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,kBAAkB,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAClD,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @category Validation Rules */\n\nimport { GraphQLError } from '../../error/GraphQLError.ts';\n\nimport type { NameNode } from '../../language/ast.ts';\nimport type { ASTVisitor } from '../../language/visitor.ts';\n\nimport type { ASTValidationContext } from '../ValidationContext.ts';\n\n/**\n * Unique fragment names\n *\n * A GraphQL document is only valid if all defined fragments have unique names.\n *\n * See https://spec.graphql.org/draft/#sec-Fragment-Name-Uniqueness\n * @param context - The validation context used while checking the document.\n * @returns A visitor that reports validation errors for this rule.\n * @example\n * ```ts\n * import { buildSchema, parse, validate } from 'graphql';\n * import { UniqueFragmentNamesRule } from 'graphql/validation';\n *\n * const schema = buildSchema(`\n * type Query {\n * name: String\n * }\n * `);\n *\n * const invalidDocument = parse(`\n * fragment A on Query { name } fragment A on Query { name } query { ...A }\n * `);\n * const invalidErrors = validate(schema, invalidDocument, [\n * UniqueFragmentNamesRule,\n * ]);\n *\n * invalidErrors.length; // => 1\n *\n * const validDocument = parse(`\n * fragment A on Query { name } query { ...A }\n * `);\n * const validErrors = validate(schema, validDocument, [UniqueFragmentNamesRule]);\n *\n * validErrors; // => []\n * ```\n */\nexport function UniqueFragmentNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n const knownFragmentNames = new Map<string, NameNode>();\n return {\n OperationDefinition: () => false,\n FragmentDefinition(node) {\n const fragmentName = node.name.value;\n const knownFragmentName = knownFragmentNames.get(fragmentName);\n if (knownFragmentName != null) {\n context.reportError(\n new GraphQLError(\n `There can be only one fragment named \"${fragmentName}\".`,\n { nodes: [knownFragmentName, node.name] },\n ),\n );\n } else {\n knownFragmentNames.set(fragmentName, node.name);\n }\n return false;\n },\n };\n}\n"]}
|
|
@@ -28,14 +28,18 @@ import type { ASTValidationContext } from "../ValidationContext.mjs";
|
|
|
28
28
|
* const invalidDocument = parse(`
|
|
29
29
|
* { search(filter: { name: "a", name: "b" }) }
|
|
30
30
|
* `);
|
|
31
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
31
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
32
|
+
* UniqueInputFieldNamesRule,
|
|
33
|
+
* ]);
|
|
32
34
|
*
|
|
33
35
|
* invalidErrors.length; // => 1
|
|
34
36
|
*
|
|
35
37
|
* const validDocument = parse(`
|
|
36
38
|
* { search(filter: { name: "a" }) }
|
|
37
39
|
* `);
|
|
38
|
-
* const validErrors = validate(schema, validDocument, [
|
|
40
|
+
* const validErrors = validate(schema, validDocument, [
|
|
41
|
+
* UniqueInputFieldNamesRule,
|
|
42
|
+
* ]);
|
|
39
43
|
*
|
|
40
44
|
* validErrors; // => []
|
|
41
45
|
* ```
|
|
@@ -28,14 +28,18 @@ import type { ASTValidationContext } from "../ValidationContext.js";
|
|
|
28
28
|
* const invalidDocument = parse(`
|
|
29
29
|
* { search(filter: { name: "a", name: "b" }) }
|
|
30
30
|
* `);
|
|
31
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
31
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
32
|
+
* UniqueInputFieldNamesRule,
|
|
33
|
+
* ]);
|
|
32
34
|
*
|
|
33
35
|
* invalidErrors.length; // => 1
|
|
34
36
|
*
|
|
35
37
|
* const validDocument = parse(`
|
|
36
38
|
* { search(filter: { name: "a" }) }
|
|
37
39
|
* `);
|
|
38
|
-
* const validErrors = validate(schema, validDocument, [
|
|
40
|
+
* const validErrors = validate(schema, validDocument, [
|
|
41
|
+
* UniqueInputFieldNamesRule,
|
|
42
|
+
* ]);
|
|
39
43
|
*
|
|
40
44
|
* validErrors; // => []
|
|
41
45
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniqueInputFieldNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueInputFieldNamesRule.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"UniqueInputFieldNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueInputFieldNamesRule.ts"],"names":[],"mappings":";;AAsDA,8DAiCC;AArFD,6DAAuD;AAEvD,iEAA2D;AAkD3D,SAAgB,yBAAyB,CACvC,OAA6B;IAE7B,MAAM,cAAc,GAAiC,EAAE,CAAC;IACxD,IAAI,UAAU,GAAG,IAAI,GAAG,EAAoB,CAAC;IAE7C,OAAO;QACL,WAAW,EAAE;YACX,KAAK;gBACH,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAChC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;YACzB,CAAC;YACD,KAAK;gBACH,MAAM,cAAc,GAAG,cAAc,CAAC,GAAG,EAAE,CAAC;sBAClC,cAAc,IAAI,IAAI;wBAAhC,wBAAS;gBACT,UAAU,GAAG,cAAc,CAAC;YAC9B,CAAC;SACF;QACD,WAAW,CAAC,IAAI;YACd,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YAClC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC5C,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;gBACtB,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,4CAA4C,SAAS,IAAI,EACzD,EAAE,KAAK,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAClC,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @category Validation Rules */\n\nimport { invariant } from '../../jsutils/invariant.ts';\n\nimport { GraphQLError } from '../../error/GraphQLError.ts';\n\nimport type { NameNode } from '../../language/ast.ts';\nimport type { ASTVisitor } from '../../language/visitor.ts';\n\nimport type { ASTValidationContext } from '../ValidationContext.ts';\n\n/**\n * Unique input field names\n *\n * A GraphQL input object value is only valid if all supplied fields are\n * uniquely named.\n *\n * See https://spec.graphql.org/draft/#sec-Input-Object-Field-Uniqueness\n * @param context - The validation context used while checking the document.\n * @returns A visitor that reports validation errors for this rule.\n * @example\n * ```ts\n * import { buildSchema, parse, validate } from 'graphql';\n * import { UniqueInputFieldNamesRule } from 'graphql/validation';\n *\n * const schema = buildSchema(`\n * input Filter {\n * name: String\n * }\n *\n * type Query {\n * search(filter: Filter): String\n * }\n * `);\n *\n * const invalidDocument = parse(`\n * { search(filter: { name: \"a\", name: \"b\" }) }\n * `);\n * const invalidErrors = validate(schema, invalidDocument, [\n * UniqueInputFieldNamesRule,\n * ]);\n *\n * invalidErrors.length; // => 1\n *\n * const validDocument = parse(`\n * { search(filter: { name: \"a\" }) }\n * `);\n * const validErrors = validate(schema, validDocument, [\n * UniqueInputFieldNamesRule,\n * ]);\n *\n * validErrors; // => []\n * ```\n */\nexport function UniqueInputFieldNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n const knownNameStack: Array<Map<string, NameNode>> = [];\n let knownNames = new Map<string, NameNode>();\n\n return {\n ObjectValue: {\n enter() {\n knownNameStack.push(knownNames);\n knownNames = new Map();\n },\n leave() {\n const prevKnownNames = knownNameStack.pop();\n invariant(prevKnownNames != null);\n knownNames = prevKnownNames;\n },\n },\n ObjectField(node) {\n const fieldName = node.name.value;\n const knownName = knownNames.get(fieldName);\n if (knownName != null) {\n context.reportError(\n new GraphQLError(\n `There can be only one input field named \"${fieldName}\".`,\n { nodes: [knownName, node.name] },\n ),\n );\n } else {\n knownNames.set(fieldName, node.name);\n }\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniqueInputFieldNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueInputFieldNamesRule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,oCAAmC;AAEvD,OAAO,EAAE,YAAY,EAAE,qCAAoC;
|
|
1
|
+
{"version":3,"file":"UniqueInputFieldNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueInputFieldNamesRule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,oCAAmC;AAEvD,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAkD3D,MAAM,UAAU,yBAAyB,CACvC,OAA6B;IAE7B,MAAM,cAAc,GAAiC,EAAE,CAAC;IACxD,IAAI,UAAU,GAAG,IAAI,GAAG,EAAoB,CAAC;IAE7C,OAAO;QACL,WAAW,EAAE;YACX,KAAK;gBACH,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAChC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;YACzB,CAAC;YACD,KAAK;gBACH,MAAM,cAAc,GAAG,cAAc,CAAC,GAAG,EAAE,CAAC;sBAClC,cAAc,IAAI,IAAI;oBAAhC,SAAS;gBACT,UAAU,GAAG,cAAc,CAAC;YAC9B,CAAC;SACF;QACD,WAAW,CAAC,IAAI;YACd,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YAClC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC5C,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;gBACtB,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,4CAA4C,SAAS,IAAI,EACzD,EAAE,KAAK,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAClC,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @category Validation Rules */\n\nimport { invariant } from '../../jsutils/invariant.ts';\n\nimport { GraphQLError } from '../../error/GraphQLError.ts';\n\nimport type { NameNode } from '../../language/ast.ts';\nimport type { ASTVisitor } from '../../language/visitor.ts';\n\nimport type { ASTValidationContext } from '../ValidationContext.ts';\n\n/**\n * Unique input field names\n *\n * A GraphQL input object value is only valid if all supplied fields are\n * uniquely named.\n *\n * See https://spec.graphql.org/draft/#sec-Input-Object-Field-Uniqueness\n * @param context - The validation context used while checking the document.\n * @returns A visitor that reports validation errors for this rule.\n * @example\n * ```ts\n * import { buildSchema, parse, validate } from 'graphql';\n * import { UniqueInputFieldNamesRule } from 'graphql/validation';\n *\n * const schema = buildSchema(`\n * input Filter {\n * name: String\n * }\n *\n * type Query {\n * search(filter: Filter): String\n * }\n * `);\n *\n * const invalidDocument = parse(`\n * { search(filter: { name: \"a\", name: \"b\" }) }\n * `);\n * const invalidErrors = validate(schema, invalidDocument, [\n * UniqueInputFieldNamesRule,\n * ]);\n *\n * invalidErrors.length; // => 1\n *\n * const validDocument = parse(`\n * { search(filter: { name: \"a\" }) }\n * `);\n * const validErrors = validate(schema, validDocument, [\n * UniqueInputFieldNamesRule,\n * ]);\n *\n * validErrors; // => []\n * ```\n */\nexport function UniqueInputFieldNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n const knownNameStack: Array<Map<string, NameNode>> = [];\n let knownNames = new Map<string, NameNode>();\n\n return {\n ObjectValue: {\n enter() {\n knownNameStack.push(knownNames);\n knownNames = new Map();\n },\n leave() {\n const prevKnownNames = knownNameStack.pop();\n invariant(prevKnownNames != null);\n knownNames = prevKnownNames;\n },\n },\n ObjectField(node) {\n const fieldName = node.name.value;\n const knownName = knownNames.get(fieldName);\n if (knownName != null) {\n context.reportError(\n new GraphQLError(\n `There can be only one input field named \"${fieldName}\".`,\n { nodes: [knownName, node.name] },\n ),\n );\n } else {\n knownNames.set(fieldName, node.name);\n }\n },\n };\n}\n"]}
|
|
@@ -23,7 +23,9 @@ import type { ASTValidationContext } from "../ValidationContext.mjs";
|
|
|
23
23
|
* const invalidDocument = parse(`
|
|
24
24
|
* query Same { name } query Same { name }
|
|
25
25
|
* `);
|
|
26
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
26
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* UniqueOperationNamesRule,
|
|
28
|
+
* ]);
|
|
27
29
|
*
|
|
28
30
|
* invalidErrors.length; // => 1
|
|
29
31
|
*
|
|
@@ -23,7 +23,9 @@ import type { ASTValidationContext } from "../ValidationContext.js";
|
|
|
23
23
|
* const invalidDocument = parse(`
|
|
24
24
|
* query Same { name } query Same { name }
|
|
25
25
|
* `);
|
|
26
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
26
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* UniqueOperationNamesRule,
|
|
28
|
+
* ]);
|
|
27
29
|
*
|
|
28
30
|
* invalidErrors.length; // => 1
|
|
29
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniqueOperationNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueOperationNamesRule.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"UniqueOperationNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueOperationNamesRule.ts"],"names":[],"mappings":";;AA6CA,4DAwBC;AAnED,iEAA2D;AA2C3D,SAAgB,wBAAwB,CACtC,OAA6B;IAE7B,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAoB,CAAC;IACxD,OAAO;QACL,mBAAmB,CAAC,IAAI;YACtB,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC;YAChC,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;gBAC1B,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBACxE,IAAI,kBAAkB,IAAI,IAAI,EAAE,CAAC;oBAC/B,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,0CAA0C,aAAa,CAAC,KAAK,IAAI,EACjE,EAAE,KAAK,EAAE,CAAC,kBAAkB,EAAE,aAAa,CAAC,EAAE,CAC/C,CACF,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;gBAC9D,CAAC;YACH,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,kBAAkB,EAAE,GAAG,EAAE,CAAC,KAAK;KAChC,CAAC;AACJ,CAAC","sourcesContent":["/** @category Validation Rules */\n\nimport { GraphQLError } from '../../error/GraphQLError.ts';\n\nimport type { NameNode } from '../../language/ast.ts';\nimport type { ASTVisitor } from '../../language/visitor.ts';\n\nimport type { ASTValidationContext } from '../ValidationContext.ts';\n\n/**\n * Unique operation names\n *\n * A GraphQL document is only valid if all defined operations have unique names.\n *\n * See https://spec.graphql.org/draft/#sec-Operation-Name-Uniqueness\n * @param context - The validation context used while checking the document.\n * @returns A visitor that reports validation errors for this rule.\n * @example\n * ```ts\n * import { buildSchema, parse, validate } from 'graphql';\n * import { UniqueOperationNamesRule } from 'graphql/validation';\n *\n * const schema = buildSchema(`\n * type Query {\n * name: String\n * }\n * `);\n *\n * const invalidDocument = parse(`\n * query Same { name } query Same { name }\n * `);\n * const invalidErrors = validate(schema, invalidDocument, [\n * UniqueOperationNamesRule,\n * ]);\n *\n * invalidErrors.length; // => 1\n *\n * const validDocument = parse(`\n * query One { name } query Two { name }\n * `);\n * const validErrors = validate(schema, validDocument, [UniqueOperationNamesRule]);\n *\n * validErrors; // => []\n * ```\n */\nexport function UniqueOperationNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n const knownOperationNames = new Map<string, NameNode>();\n return {\n OperationDefinition(node) {\n const operationName = node.name;\n if (operationName != null) {\n const knownOperationName = knownOperationNames.get(operationName.value);\n if (knownOperationName != null) {\n context.reportError(\n new GraphQLError(\n `There can be only one operation named \"${operationName.value}\".`,\n { nodes: [knownOperationName, operationName] },\n ),\n );\n } else {\n knownOperationNames.set(operationName.value, operationName);\n }\n }\n return false;\n },\n FragmentDefinition: () => false,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniqueOperationNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueOperationNamesRule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,qCAAoC;
|
|
1
|
+
{"version":3,"file":"UniqueOperationNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueOperationNamesRule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,qCAAoC;AA2C3D,MAAM,UAAU,wBAAwB,CACtC,OAA6B;IAE7B,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAoB,CAAC;IACxD,OAAO;QACL,mBAAmB,CAAC,IAAI;YACtB,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC;YAChC,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;gBAC1B,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBACxE,IAAI,kBAAkB,IAAI,IAAI,EAAE,CAAC;oBAC/B,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,0CAA0C,aAAa,CAAC,KAAK,IAAI,EACjE,EAAE,KAAK,EAAE,CAAC,kBAAkB,EAAE,aAAa,CAAC,EAAE,CAC/C,CACF,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;gBAC9D,CAAC;YACH,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,kBAAkB,EAAE,GAAG,EAAE,CAAC,KAAK;KAChC,CAAC;AACJ,CAAC","sourcesContent":["/** @category Validation Rules */\n\nimport { GraphQLError } from '../../error/GraphQLError.ts';\n\nimport type { NameNode } from '../../language/ast.ts';\nimport type { ASTVisitor } from '../../language/visitor.ts';\n\nimport type { ASTValidationContext } from '../ValidationContext.ts';\n\n/**\n * Unique operation names\n *\n * A GraphQL document is only valid if all defined operations have unique names.\n *\n * See https://spec.graphql.org/draft/#sec-Operation-Name-Uniqueness\n * @param context - The validation context used while checking the document.\n * @returns A visitor that reports validation errors for this rule.\n * @example\n * ```ts\n * import { buildSchema, parse, validate } from 'graphql';\n * import { UniqueOperationNamesRule } from 'graphql/validation';\n *\n * const schema = buildSchema(`\n * type Query {\n * name: String\n * }\n * `);\n *\n * const invalidDocument = parse(`\n * query Same { name } query Same { name }\n * `);\n * const invalidErrors = validate(schema, invalidDocument, [\n * UniqueOperationNamesRule,\n * ]);\n *\n * invalidErrors.length; // => 1\n *\n * const validDocument = parse(`\n * query One { name } query Two { name }\n * `);\n * const validErrors = validate(schema, validDocument, [UniqueOperationNamesRule]);\n *\n * validErrors; // => []\n * ```\n */\nexport function UniqueOperationNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n const knownOperationNames = new Map<string, NameNode>();\n return {\n OperationDefinition(node) {\n const operationName = node.name;\n if (operationName != null) {\n const knownOperationName = knownOperationNames.get(operationName.value);\n if (knownOperationName != null) {\n context.reportError(\n new GraphQLError(\n `There can be only one operation named \"${operationName.value}\".`,\n { nodes: [knownOperationName, operationName] },\n ),\n );\n } else {\n knownOperationNames.set(operationName.value, operationName);\n }\n }\n return false;\n },\n FragmentDefinition: () => false,\n };\n}\n"]}
|
|
@@ -21,7 +21,9 @@ import type { ASTValidationContext } from "../ValidationContext.mjs";
|
|
|
21
21
|
* const invalidDocument = parse(`
|
|
22
22
|
* query ($id: ID, $id: ID) { field(arg: $id) }
|
|
23
23
|
* `);
|
|
24
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
24
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
25
|
+
* UniqueVariableNamesRule,
|
|
26
|
+
* ]);
|
|
25
27
|
*
|
|
26
28
|
* invalidErrors.length; // => 1
|
|
27
29
|
*
|
|
@@ -21,7 +21,9 @@ import type { ASTValidationContext } from "../ValidationContext.js";
|
|
|
21
21
|
* const invalidDocument = parse(`
|
|
22
22
|
* query ($id: ID, $id: ID) { field(arg: $id) }
|
|
23
23
|
* `);
|
|
24
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
24
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
25
|
+
* UniqueVariableNamesRule,
|
|
26
|
+
* ]);
|
|
25
27
|
*
|
|
26
28
|
* invalidErrors.length; // => 1
|
|
27
29
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniqueVariableNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueVariableNamesRule.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"UniqueVariableNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueVariableNamesRule.ts"],"names":[],"mappings":";;AA4CA,0DAwBC;AAlED,yDAAmD;AAEnD,iEAA2D;AAwC3D,SAAgB,uBAAuB,CACrC,OAA6B;IAE7B,OAAO;QACL,mBAAmB,CAAC,aAAa;YAC/B,MAAM,mBAAmB,GAAG,aAAa,CAAC,mBAAmB,IAAI,EAAE,CAAC;YAEpE,MAAM,uBAAuB,GAAG,IAAA,oBAAO,EACrC,mBAAmB,EACnB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CACnC,CAAC;YAEF,KAAK,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,IAAI,uBAAuB,EAAE,CAAC;gBACpE,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC7B,OAAO,CAAC,WAAW,CACjB,IAAI,8BAAY,CACd,0CAA0C,YAAY,IAAI,EAC1D,EAAE,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAC3D,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @category Validation Rules */\n\nimport { groupBy } from '../../jsutils/groupBy.ts';\n\nimport { GraphQLError } from '../../error/GraphQLError.ts';\n\nimport type { ASTVisitor } from '../../language/visitor.ts';\n\nimport type { ASTValidationContext } from '../ValidationContext.ts';\n\n/**\n * Unique variable names\n *\n * A GraphQL operation is only valid if all its variables are uniquely named.\n * @param context - The validation context used while checking the document.\n * @returns A visitor that reports validation errors for this rule.\n * @example\n * ```ts\n * import { buildSchema, parse, validate } from 'graphql';\n * import { UniqueVariableNamesRule } from 'graphql/validation';\n *\n * const schema = buildSchema(`\n * type Query {\n * field(arg: ID): String\n * }\n * `);\n *\n * const invalidDocument = parse(`\n * query ($id: ID, $id: ID) { field(arg: $id) }\n * `);\n * const invalidErrors = validate(schema, invalidDocument, [\n * UniqueVariableNamesRule,\n * ]);\n *\n * invalidErrors.length; // => 1\n *\n * const validDocument = parse(`\n * query ($id: ID) { field(arg: $id) }\n * `);\n * const validErrors = validate(schema, validDocument, [UniqueVariableNamesRule]);\n *\n * validErrors; // => []\n * ```\n */\nexport function UniqueVariableNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n return {\n OperationDefinition(operationNode) {\n const variableDefinitions = operationNode.variableDefinitions ?? [];\n\n const seenVariableDefinitions = groupBy(\n variableDefinitions,\n (node) => node.variable.name.value,\n );\n\n for (const [variableName, variableNodes] of seenVariableDefinitions) {\n if (variableNodes.length > 1) {\n context.reportError(\n new GraphQLError(\n `There can be only one variable named \"$${variableName}\".`,\n { nodes: variableNodes.map((node) => node.variable.name) },\n ),\n );\n }\n }\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniqueVariableNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueVariableNamesRule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,kCAAiC;AAEnD,OAAO,EAAE,YAAY,EAAE,qCAAoC;
|
|
1
|
+
{"version":3,"file":"UniqueVariableNamesRule.js","sourceRoot":"","sources":["../../../src/validation/rules/UniqueVariableNamesRule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,kCAAiC;AAEnD,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAwC3D,MAAM,UAAU,uBAAuB,CACrC,OAA6B;IAE7B,OAAO;QACL,mBAAmB,CAAC,aAAa;YAC/B,MAAM,mBAAmB,GAAG,aAAa,CAAC,mBAAmB,IAAI,EAAE,CAAC;YAEpE,MAAM,uBAAuB,GAAG,OAAO,CACrC,mBAAmB,EACnB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CACnC,CAAC;YAEF,KAAK,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,IAAI,uBAAuB,EAAE,CAAC;gBACpE,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC7B,OAAO,CAAC,WAAW,CACjB,IAAI,YAAY,CACd,0CAA0C,YAAY,IAAI,EAC1D,EAAE,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAC3D,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @category Validation Rules */\n\nimport { groupBy } from '../../jsutils/groupBy.ts';\n\nimport { GraphQLError } from '../../error/GraphQLError.ts';\n\nimport type { ASTVisitor } from '../../language/visitor.ts';\n\nimport type { ASTValidationContext } from '../ValidationContext.ts';\n\n/**\n * Unique variable names\n *\n * A GraphQL operation is only valid if all its variables are uniquely named.\n * @param context - The validation context used while checking the document.\n * @returns A visitor that reports validation errors for this rule.\n * @example\n * ```ts\n * import { buildSchema, parse, validate } from 'graphql';\n * import { UniqueVariableNamesRule } from 'graphql/validation';\n *\n * const schema = buildSchema(`\n * type Query {\n * field(arg: ID): String\n * }\n * `);\n *\n * const invalidDocument = parse(`\n * query ($id: ID, $id: ID) { field(arg: $id) }\n * `);\n * const invalidErrors = validate(schema, invalidDocument, [\n * UniqueVariableNamesRule,\n * ]);\n *\n * invalidErrors.length; // => 1\n *\n * const validDocument = parse(`\n * query ($id: ID) { field(arg: $id) }\n * `);\n * const validErrors = validate(schema, validDocument, [UniqueVariableNamesRule]);\n *\n * validErrors; // => []\n * ```\n */\nexport function UniqueVariableNamesRule(\n context: ASTValidationContext,\n): ASTVisitor {\n return {\n OperationDefinition(operationNode) {\n const variableDefinitions = operationNode.variableDefinitions ?? [];\n\n const seenVariableDefinitions = groupBy(\n variableDefinitions,\n (node) => node.variable.name.value,\n );\n\n for (const [variableName, variableNodes] of seenVariableDefinitions) {\n if (variableNodes.length > 1) {\n context.reportError(\n new GraphQLError(\n `There can be only one variable named \"$${variableName}\".`,\n { nodes: variableNodes.map((node) => node.variable.name) },\n ),\n );\n }\n }\n },\n };\n}\n"]}
|
|
@@ -24,7 +24,9 @@ import type { ValidationContext } from "../ValidationContext.mjs";
|
|
|
24
24
|
* const invalidDocument = parse(`
|
|
25
25
|
* { count(limit: "many") }
|
|
26
26
|
* `);
|
|
27
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
28
|
+
* ValuesOfCorrectTypeRule,
|
|
29
|
+
* ]);
|
|
28
30
|
*
|
|
29
31
|
* invalidErrors.length; // => 1
|
|
30
32
|
*
|
|
@@ -24,7 +24,9 @@ import type { ValidationContext } from "../ValidationContext.js";
|
|
|
24
24
|
* const invalidDocument = parse(`
|
|
25
25
|
* { count(limit: "many") }
|
|
26
26
|
* `);
|
|
27
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
27
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
28
|
+
* ValuesOfCorrectTypeRule,
|
|
29
|
+
* ]);
|
|
28
30
|
*
|
|
29
31
|
* invalidErrors.length; // => 1
|
|
30
32
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValuesOfCorrectTypeRule.js","sourceRoot":"","sources":["../../../src/validation/rules/ValuesOfCorrectTypeRule.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"ValuesOfCorrectTypeRule.js","sourceRoot":"","sources":["../../../src/validation/rules/ValuesOfCorrectTypeRule.ts"],"names":[],"mappings":";;AAkDA,0DA2BC;AApED,iFAA6E;AAyC7E,SAAgB,uBAAuB,CACrC,OAA0B;IAE1B,OAAO;QACL,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAGlB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC/D,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CACpB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QAC3E,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CACnB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QAMzD,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CACpB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CACrB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;KAC1D,CAAC;AACJ,CAAC;AAQD,SAAS,gBAAgB,CACvB,OAA0B,EAC1B,IAAe,EACf,SAAkC;IAElC,IAAI,SAAS,EAAE,CAAC;QACd,IAAA,4CAAoB,EAClB,IAAI,EACJ,SAAS,EACT,CAAC,KAAK,EAAE,EAAE;YACR,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC,EACD,SAAS,EACT,SAAS,EACT,OAAO,CAAC,eAAe,CACxB,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/** @category Validation Rules */\n\nimport type { Maybe } from '../../jsutils/Maybe.ts';\n\nimport type { ValueNode } from '../../language/ast.ts';\nimport type { ASTVisitor } from '../../language/visitor.ts';\n\nimport type { GraphQLInputType } from '../../type/index.ts';\n\nimport { validateInputLiteral } from '../../utilities/validateInputValue.ts';\n\nimport type { ValidationContext } from '../ValidationContext.ts';\n\n/**\n * Value literals of correct type\n *\n * A GraphQL document is only valid if all value literals are of the type\n * expected at their position.\n *\n * See https://spec.graphql.org/draft/#sec-Values-of-Correct-Type\n * @param context - The validation context used while checking the document.\n * @returns A visitor that reports validation errors for this rule.\n * @example\n * ```ts\n * import { buildSchema, parse, validate } from 'graphql';\n * import { ValuesOfCorrectTypeRule } from 'graphql/validation';\n *\n * const schema = buildSchema(`\n * type Query {\n * count(limit: Int): Int\n * }\n * `);\n *\n * const invalidDocument = parse(`\n * { count(limit: \"many\") }\n * `);\n * const invalidErrors = validate(schema, invalidDocument, [\n * ValuesOfCorrectTypeRule,\n * ]);\n *\n * invalidErrors.length; // => 1\n *\n * const validDocument = parse(`\n * { count(limit: 1) }\n * `);\n * const validErrors = validate(schema, validDocument, [ValuesOfCorrectTypeRule]);\n *\n * validErrors; // => []\n * ```\n */\nexport function ValuesOfCorrectTypeRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n NullValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n ListValue: (node) =>\n // Note: TypeInfo will traverse into a list's item type, so look to the\n // parent input type to check if it is a list.\n isValidValueNode(context, node, context.getParentInputType()),\n ObjectValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n EnumValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n IntValue: (node) => isValidValueNode(context, node, context.getInputType()),\n FloatValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n // Descriptions are string values that would not validate according\n // to the below logic, but since (per the specification) descriptions must\n // not affect validation, they are ignored entirely when visiting the AST\n // and do not require special handling.\n // See https://spec.graphql.org/draft/#sec-Descriptions\n StringValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n BooleanValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n };\n}\n\n/**\n * Any value literal may be a valid representation of a Scalar, depending on\n * that scalar type.\n *\n * @internal\n */\nfunction isValidValueNode(\n context: ValidationContext,\n node: ValueNode,\n inputType: Maybe<GraphQLInputType>,\n): false {\n if (inputType) {\n validateInputLiteral(\n node,\n inputType,\n (error) => {\n context.reportError(error);\n },\n undefined,\n undefined,\n context.hideSuggestions,\n );\n }\n return false;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValuesOfCorrectTypeRule.js","sourceRoot":"","sources":["../../../src/validation/rules/ValuesOfCorrectTypeRule.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,oBAAoB,EAAE,+CAA8C;
|
|
1
|
+
{"version":3,"file":"ValuesOfCorrectTypeRule.js","sourceRoot":"","sources":["../../../src/validation/rules/ValuesOfCorrectTypeRule.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,oBAAoB,EAAE,+CAA8C;AAyC7E,MAAM,UAAU,uBAAuB,CACrC,OAA0B;IAE1B,OAAO;QACL,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAGlB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC/D,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CACpB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QAC3E,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CACnB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QAMzD,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CACpB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACzD,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CACrB,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;KAC1D,CAAC;AACJ,CAAC;AAQD,SAAS,gBAAgB,CACvB,OAA0B,EAC1B,IAAe,EACf,SAAkC;IAElC,IAAI,SAAS,EAAE,CAAC;QACd,oBAAoB,CAClB,IAAI,EACJ,SAAS,EACT,CAAC,KAAK,EAAE,EAAE;YACR,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC,EACD,SAAS,EACT,SAAS,EACT,OAAO,CAAC,eAAe,CACxB,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/** @category Validation Rules */\n\nimport type { Maybe } from '../../jsutils/Maybe.ts';\n\nimport type { ValueNode } from '../../language/ast.ts';\nimport type { ASTVisitor } from '../../language/visitor.ts';\n\nimport type { GraphQLInputType } from '../../type/index.ts';\n\nimport { validateInputLiteral } from '../../utilities/validateInputValue.ts';\n\nimport type { ValidationContext } from '../ValidationContext.ts';\n\n/**\n * Value literals of correct type\n *\n * A GraphQL document is only valid if all value literals are of the type\n * expected at their position.\n *\n * See https://spec.graphql.org/draft/#sec-Values-of-Correct-Type\n * @param context - The validation context used while checking the document.\n * @returns A visitor that reports validation errors for this rule.\n * @example\n * ```ts\n * import { buildSchema, parse, validate } from 'graphql';\n * import { ValuesOfCorrectTypeRule } from 'graphql/validation';\n *\n * const schema = buildSchema(`\n * type Query {\n * count(limit: Int): Int\n * }\n * `);\n *\n * const invalidDocument = parse(`\n * { count(limit: \"many\") }\n * `);\n * const invalidErrors = validate(schema, invalidDocument, [\n * ValuesOfCorrectTypeRule,\n * ]);\n *\n * invalidErrors.length; // => 1\n *\n * const validDocument = parse(`\n * { count(limit: 1) }\n * `);\n * const validErrors = validate(schema, validDocument, [ValuesOfCorrectTypeRule]);\n *\n * validErrors; // => []\n * ```\n */\nexport function ValuesOfCorrectTypeRule(\n context: ValidationContext,\n): ASTVisitor {\n return {\n NullValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n ListValue: (node) =>\n // Note: TypeInfo will traverse into a list's item type, so look to the\n // parent input type to check if it is a list.\n isValidValueNode(context, node, context.getParentInputType()),\n ObjectValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n EnumValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n IntValue: (node) => isValidValueNode(context, node, context.getInputType()),\n FloatValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n // Descriptions are string values that would not validate according\n // to the below logic, but since (per the specification) descriptions must\n // not affect validation, they are ignored entirely when visiting the AST\n // and do not require special handling.\n // See https://spec.graphql.org/draft/#sec-Descriptions\n StringValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n BooleanValue: (node) =>\n isValidValueNode(context, node, context.getInputType()),\n };\n}\n\n/**\n * Any value literal may be a valid representation of a Scalar, depending on\n * that scalar type.\n *\n * @internal\n */\nfunction isValidValueNode(\n context: ValidationContext,\n node: ValueNode,\n inputType: Maybe<GraphQLInputType>,\n): false {\n if (inputType) {\n validateInputLiteral(\n node,\n inputType,\n (error) => {\n context.reportError(error);\n },\n undefined,\n undefined,\n context.hideSuggestions,\n );\n }\n return false;\n}\n"]}
|
|
@@ -28,14 +28,18 @@ import type { ValidationContext } from "../ValidationContext.mjs";
|
|
|
28
28
|
* const invalidDocument = parse(`
|
|
29
29
|
* query ($user: User) { field(arg: "1") }
|
|
30
30
|
* `);
|
|
31
|
-
* const invalidErrors = validate(schema, invalidDocument, [
|
|
31
|
+
* const invalidErrors = validate(schema, invalidDocument, [
|
|
32
|
+
* VariablesAreInputTypesRule,
|
|
33
|
+
* ]);
|
|
32
34
|
*
|
|
33
35
|
* invalidErrors.length; // => 1
|
|
34
36
|
*
|
|
35
37
|
* const validDocument = parse(`
|
|
36
38
|
* query ($id: ID) { field(arg: $id) }
|
|
37
39
|
* `);
|
|
38
|
-
* const validErrors = validate(schema, validDocument, [
|
|
40
|
+
* const validErrors = validate(schema, validDocument, [
|
|
41
|
+
* VariablesAreInputTypesRule,
|
|
42
|
+
* ]);
|
|
39
43
|
*
|
|
40
44
|
* validErrors; // => []
|
|
41
45
|
* ```
|