graphql 0.0.1-test.1
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 +21 -0
- package/NotSupportedTSVersion.d.ts +1 -0
- package/README.md +158 -0
- package/error/GraphQLError.d.ts +142 -0
- package/error/GraphQLError.js +267 -0
- package/error/GraphQLError.mjs +253 -0
- package/error/index.d.ts +7 -0
- package/error/index.js +41 -0
- package/error/index.mjs +3 -0
- package/error/locatedError.d.ts +13 -0
- package/error/locatedError.js +40 -0
- package/error/locatedError.mjs +32 -0
- package/error/syntaxError.d.ts +11 -0
- package/error/syntaxError.js +21 -0
- package/error/syntaxError.mjs +11 -0
- package/execution/collectFields.d.ts +45 -0
- package/execution/collectFields.js +229 -0
- package/execution/collectFields.mjs +213 -0
- package/execution/execute.d.ts +185 -0
- package/execution/execute.js +1016 -0
- package/execution/execute.mjs +988 -0
- package/execution/index.d.ts +14 -0
- package/execution/index.js +67 -0
- package/execution/index.mjs +9 -0
- package/execution/mapAsyncIterator.d.ts +9 -0
- package/execution/mapAsyncIterator.js +68 -0
- package/execution/mapAsyncIterator.mjs +61 -0
- package/execution/subscribe.d.ts +68 -0
- package/execution/subscribe.js +261 -0
- package/execution/subscribe.mjs +239 -0
- package/execution/values.d.ts +81 -0
- package/execution/values.js +292 -0
- package/execution/values.mjs +255 -0
- package/graphql.d.ts +67 -0
- package/graphql.js +96 -0
- package/graphql.mjs +122 -0
- package/index.d.ts +411 -0
- package/index.js +1263 -0
- package/index.mjs +254 -0
- package/jsutils/Maybe.d.ts +2 -0
- package/jsutils/Maybe.js +5 -0
- package/jsutils/Maybe.mjs +1 -0
- package/jsutils/ObjMap.d.ts +16 -0
- package/jsutils/ObjMap.js +5 -0
- package/jsutils/ObjMap.mjs +1 -0
- package/jsutils/Path.d.ts +20 -0
- package/jsutils/Path.js +33 -0
- package/jsutils/Path.mjs +25 -0
- package/jsutils/PromiseOrValue.d.ts +1 -0
- package/jsutils/PromiseOrValue.js +5 -0
- package/jsutils/PromiseOrValue.mjs +1 -0
- package/jsutils/devAssert.d.ts +1 -0
- package/jsutils/devAssert.js +14 -0
- package/jsutils/devAssert.mjs +7 -0
- package/jsutils/didYouMean.d.ts +8 -0
- package/jsutils/didYouMean.js +38 -0
- package/jsutils/didYouMean.mjs +32 -0
- package/jsutils/groupBy.d.ts +7 -0
- package/jsutils/groupBy.js +26 -0
- package/jsutils/groupBy.mjs +19 -0
- package/jsutils/identityFunc.d.ts +4 -0
- package/jsutils/identityFunc.js +13 -0
- package/jsutils/identityFunc.mjs +6 -0
- package/jsutils/inspect.d.ts +4 -0
- package/jsutils/inspect.js +121 -0
- package/jsutils/inspect.mjs +115 -0
- package/jsutils/instanceOf.d.ts +16 -0
- package/jsutils/instanceOf.js +60 -0
- package/jsutils/instanceOf.mjs +52 -0
- package/jsutils/invariant.d.ts +4 -0
- package/jsutils/invariant.js +16 -0
- package/jsutils/invariant.mjs +9 -0
- package/jsutils/isAsyncIterable.d.ts +7 -0
- package/jsutils/isAsyncIterable.js +18 -0
- package/jsutils/isAsyncIterable.mjs +11 -0
- package/jsutils/isIterableObject.d.ts +20 -0
- package/jsutils/isIterableObject.js +32 -0
- package/jsutils/isIterableObject.mjs +25 -0
- package/jsutils/isObjectLike.d.ts +7 -0
- package/jsutils/isObjectLike.js +14 -0
- package/jsutils/isObjectLike.mjs +7 -0
- package/jsutils/isPromise.d.ts +5 -0
- package/jsutils/isPromise.js +17 -0
- package/jsutils/isPromise.mjs +10 -0
- package/jsutils/keyMap.d.ts +32 -0
- package/jsutils/keyMap.js +43 -0
- package/jsutils/keyMap.mjs +36 -0
- package/jsutils/keyValMap.d.ts +23 -0
- package/jsutils/keyValMap.js +33 -0
- package/jsutils/keyValMap.mjs +26 -0
- package/jsutils/mapValue.d.ts +9 -0
- package/jsutils/mapValue.js +20 -0
- package/jsutils/mapValue.mjs +13 -0
- package/jsutils/memoize3.d.ts +9 -0
- package/jsutils/memoize3.js +41 -0
- package/jsutils/memoize3.mjs +34 -0
- package/jsutils/naturalCompare.d.ts +8 -0
- package/jsutils/naturalCompare.js +69 -0
- package/jsutils/naturalCompare.mjs +61 -0
- package/jsutils/printPathArray.d.ts +6 -0
- package/jsutils/printPathArray.js +17 -0
- package/jsutils/printPathArray.mjs +10 -0
- package/jsutils/promiseForObject.d.ts +11 -0
- package/jsutils/promiseForObject.js +25 -0
- package/jsutils/promiseForObject.mjs +18 -0
- package/jsutils/promiseReduce.d.ts +13 -0
- package/jsutils/promiseReduce.js +27 -0
- package/jsutils/promiseReduce.mjs +20 -0
- package/jsutils/suggestionList.d.ts +8 -0
- package/jsutils/suggestionList.js +139 -0
- package/jsutils/suggestionList.mjs +130 -0
- package/jsutils/toError.d.ts +4 -0
- package/jsutils/toError.js +25 -0
- package/jsutils/toError.mjs +18 -0
- package/jsutils/toObjMap.d.ts +5 -0
- package/jsutils/toObjMap.js +24 -0
- package/jsutils/toObjMap.mjs +17 -0
- package/language/ast.d.ts +536 -0
- package/language/ast.js +224 -0
- package/language/ast.mjs +206 -0
- package/language/blockString.d.ts +28 -0
- package/language/blockString.js +195 -0
- package/language/blockString.mjs +178 -0
- package/language/characterClasses.d.ts +47 -0
- package/language/characterClasses.js +75 -0
- package/language/characterClasses.mjs +64 -0
- package/language/directiveLocation.d.ts +32 -0
- package/language/directiveLocation.js +40 -0
- package/language/directiveLocation.mjs +31 -0
- package/language/index.d.ts +97 -0
- package/language/index.js +215 -0
- package/language/index.mjs +29 -0
- package/language/kinds.d.ts +65 -0
- package/language/kinds.js +64 -0
- package/language/kinds.mjs +55 -0
- package/language/lexer.d.ts +45 -0
- package/language/lexer.js +1006 -0
- package/language/lexer.mjs +902 -0
- package/language/location.d.ts +16 -0
- package/language/location.js +38 -0
- package/language/location.mjs +30 -0
- package/language/parser.d.ts +554 -0
- package/language/parser.js +1567 -0
- package/language/parser.mjs +1524 -0
- package/language/predicates.d.ts +33 -0
- package/language/predicates.js +109 -0
- package/language/predicates.mjs +81 -0
- package/language/printLocation.d.ts +14 -0
- package/language/printLocation.js +74 -0
- package/language/printLocation.mjs +66 -0
- package/language/printString.d.ts +5 -0
- package/language/printString.js +183 -0
- package/language/printString.mjs +176 -0
- package/language/printer.d.ts +6 -0
- package/language/printer.js +351 -0
- package/language/printer.mjs +339 -0
- package/language/source.d.ts +25 -0
- package/language/source.js +65 -0
- package/language/source.mjs +50 -0
- package/language/tokenKind.d.ts +34 -0
- package/language/tokenKind.js +44 -0
- package/language/tokenKind.mjs +35 -0
- package/language/visitor.d.ts +194 -0
- package/language/visitor.js +377 -0
- package/language/visitor.mjs +361 -0
- package/package.json +40 -0
- package/subscription/index.d.ts +19 -0
- package/subscription/index.js +19 -0
- package/subscription/index.mjs +19 -0
- package/type/assertName.d.ts +10 -0
- package/type/assertName.js +59 -0
- package/type/assertName.mjs +44 -0
- package/type/definition.d.ts +917 -0
- package/type/definition.js +1329 -0
- package/type/definition.mjs +1167 -0
- package/type/directives.d.ts +86 -0
- package/type/directives.js +224 -0
- package/type/directives.mjs +190 -0
- package/type/index.d.ts +150 -0
- package/type/index.js +547 -0
- package/type/index.mjs +103 -0
- package/type/introspection.d.ts +29 -0
- package/type/introspection.js +617 -0
- package/type/introspection.mjs +550 -0
- package/type/scalars.d.ts +19 -0
- package/type/scalars.js +359 -0
- package/type/scalars.mjs +299 -0
- package/type/schema.d.ts +170 -0
- package/type/schema.js +402 -0
- package/type/schema.mjs +381 -0
- package/type/validate.d.ts +17 -0
- package/type/validate.js +672 -0
- package/type/validate.mjs +647 -0
- package/utilities/TypeInfo.d.ts +67 -0
- package/utilities/TypeInfo.js +418 -0
- package/utilities/TypeInfo.mjs +395 -0
- package/utilities/assertValidName.d.ts +13 -0
- package/utilities/assertValidName.js +51 -0
- package/utilities/assertValidName.mjs +40 -0
- package/utilities/astFromValue.d.ts +28 -0
- package/utilities/astFromValue.js +190 -0
- package/utilities/astFromValue.mjs +177 -0
- package/utilities/buildASTSchema.d.ts +35 -0
- package/utilities/buildASTSchema.js +115 -0
- package/utilities/buildASTSchema.mjs +97 -0
- package/utilities/buildClientSchema.d.ts +19 -0
- package/utilities/buildClientSchema.js +386 -0
- package/utilities/buildClientSchema.mjs +363 -0
- package/utilities/coerceInputValue.d.ts +16 -0
- package/utilities/coerceInputValue.js +191 -0
- package/utilities/coerceInputValue.mjs +172 -0
- package/utilities/concatAST.d.ts +9 -0
- package/utilities/concatAST.js +26 -0
- package/utilities/concatAST.mjs +19 -0
- package/utilities/extendSchema.d.ts +40 -0
- package/utilities/extendSchema.js +798 -0
- package/utilities/extendSchema.mjs +789 -0
- package/utilities/findBreakingChanges.d.ts +51 -0
- package/utilities/findBreakingChanges.js +547 -0
- package/utilities/findBreakingChanges.mjs +516 -0
- package/utilities/getIntrospectionQuery.d.ts +182 -0
- package/utilities/getIntrospectionQuery.js +134 -0
- package/utilities/getIntrospectionQuery.mjs +127 -0
- package/utilities/getOperationAST.d.ts +11 -0
- package/utilities/getOperationAST.js +43 -0
- package/utilities/getOperationAST.mjs +36 -0
- package/utilities/getOperationRootType.d.ts +15 -0
- package/utilities/getOperationRootType.js +59 -0
- package/utilities/getOperationRootType.mjs +52 -0
- package/utilities/index.d.ts +61 -0
- package/utilities/index.js +233 -0
- package/utilities/index.mjs +55 -0
- package/utilities/introspectionFromSchema.d.ts +18 -0
- package/utilities/introspectionFromSchema.js +42 -0
- package/utilities/introspectionFromSchema.mjs +30 -0
- package/utilities/lexicographicSortSchema.d.ts +9 -0
- package/utilities/lexicographicSortSchema.js +177 -0
- package/utilities/lexicographicSortSchema.mjs +172 -0
- package/utilities/printSchema.d.ts +5 -0
- package/utilities/printSchema.js +333 -0
- package/utilities/printSchema.mjs +309 -0
- package/utilities/separateOperations.d.ts +11 -0
- package/utilities/separateOperations.js +88 -0
- package/utilities/separateOperations.mjs +80 -0
- package/utilities/sortValueNode.d.ts +9 -0
- package/utilities/sortValueNode.js +47 -0
- package/utilities/sortValueNode.mjs +39 -0
- package/utilities/stripIgnoredCharacters.d.ts +62 -0
- package/utilities/stripIgnoredCharacters.js +121 -0
- package/utilities/stripIgnoredCharacters.mjs +104 -0
- package/utilities/typeComparators.d.ts +32 -0
- package/utilities/typeComparators.js +116 -0
- package/utilities/typeComparators.mjs +106 -0
- package/utilities/typeFromAST.d.ts +32 -0
- package/utilities/typeFromAST.js +27 -0
- package/utilities/typeFromAST.mjs +18 -0
- package/utilities/typedQueryDocumentNode.d.ts +22 -0
- package/utilities/typedQueryDocumentNode.js +5 -0
- package/utilities/typedQueryDocumentNode.mjs +1 -0
- package/utilities/valueFromAST.d.ts +29 -0
- package/utilities/valueFromAST.js +185 -0
- package/utilities/valueFromAST.mjs +172 -0
- package/utilities/valueFromASTUntyped.d.ts +23 -0
- package/utilities/valueFromASTUntyped.js +61 -0
- package/utilities/valueFromASTUntyped.mjs +53 -0
- package/validation/ValidationContext.d.ts +95 -0
- package/validation/ValidationContext.js +232 -0
- package/validation/ValidationContext.mjs +212 -0
- package/validation/index.d.ts +40 -0
- package/validation/index.js +317 -0
- package/validation/index.mjs +68 -0
- package/validation/rules/ExecutableDefinitionsRule.d.ts +13 -0
- package/validation/rules/ExecutableDefinitionsRule.js +44 -0
- package/validation/rules/ExecutableDefinitionsRule.mjs +35 -0
- package/validation/rules/FieldsOnCorrectTypeRule.d.ts +13 -0
- package/validation/rules/FieldsOnCorrectTypeRule.js +143 -0
- package/validation/rules/FieldsOnCorrectTypeRule.mjs +125 -0
- package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +14 -0
- package/validation/rules/FragmentsOnCompositeTypesRule.js +65 -0
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs +49 -0
- package/validation/rules/KnownArgumentNamesRule.d.ts +23 -0
- package/validation/rules/KnownArgumentNamesRule.js +116 -0
- package/validation/rules/KnownArgumentNamesRule.mjs +98 -0
- package/validation/rules/KnownDirectivesRule.d.ts +16 -0
- package/validation/rules/KnownDirectivesRule.js +163 -0
- package/validation/rules/KnownDirectivesRule.mjs +146 -0
- package/validation/rules/KnownFragmentNamesRule.d.ts +13 -0
- package/validation/rules/KnownFragmentNamesRule.js +34 -0
- package/validation/rules/KnownFragmentNamesRule.mjs +24 -0
- package/validation/rules/KnownTypeNamesRule.d.ts +16 -0
- package/validation/rules/KnownTypeNamesRule.js +87 -0
- package/validation/rules/KnownTypeNamesRule.mjs +75 -0
- package/validation/rules/LoneAnonymousOperationRule.d.ts +13 -0
- package/validation/rules/LoneAnonymousOperationRule.js +40 -0
- package/validation/rules/LoneAnonymousOperationRule.mjs +32 -0
- package/validation/rules/LoneSchemaDefinitionRule.d.ts +10 -0
- package/validation/rules/LoneSchemaDefinitionRule.js +63 -0
- package/validation/rules/LoneSchemaDefinitionRule.mjs +53 -0
- package/validation/rules/NoFragmentCyclesRule.d.ts +13 -0
- package/validation/rules/NoFragmentCyclesRule.js +83 -0
- package/validation/rules/NoFragmentCyclesRule.mjs +76 -0
- package/validation/rules/NoUndefinedVariablesRule.d.ts +13 -0
- package/validation/rules/NoUndefinedVariablesRule.js +50 -0
- package/validation/rules/NoUndefinedVariablesRule.mjs +43 -0
- package/validation/rules/NoUnusedFragmentsRule.d.ts +13 -0
- package/validation/rules/NoUnusedFragmentsRule.js +59 -0
- package/validation/rules/NoUnusedFragmentsRule.mjs +52 -0
- package/validation/rules/NoUnusedVariablesRule.d.ts +13 -0
- package/validation/rules/NoUnusedVariablesRule.js +55 -0
- package/validation/rules/NoUnusedVariablesRule.mjs +48 -0
- package/validation/rules/OverlappingFieldsCanBeMergedRule-old.js +805 -0
- package/validation/rules/OverlappingFieldsCanBeMergedRule-old.mjs +788 -0
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +14 -0
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js +805 -0
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +788 -0
- package/validation/rules/PossibleFragmentSpreadsRule.d.ts +12 -0
- package/validation/rules/PossibleFragmentSpreadsRule.js +91 -0
- package/validation/rules/PossibleFragmentSpreadsRule.mjs +69 -0
- package/validation/rules/PossibleTypeExtensionsRule.d.ts +10 -0
- package/validation/rules/PossibleTypeExtensionsRule.js +167 -0
- package/validation/rules/PossibleTypeExtensionsRule.mjs +147 -0
- package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +20 -0
- package/validation/rules/ProvidedRequiredArgumentsRule.js +158 -0
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs +138 -0
- package/validation/rules/ScalarLeafsRule.d.ts +9 -0
- package/validation/rules/ScalarLeafsRule.js +51 -0
- package/validation/rules/ScalarLeafsRule.mjs +42 -0
- package/validation/rules/SingleFieldSubscriptionsRule.d.ts +13 -0
- package/validation/rules/SingleFieldSubscriptionsRule.js +82 -0
- package/validation/rules/SingleFieldSubscriptionsRule.mjs +73 -0
- package/validation/rules/UniqueArgumentDefinitionNamesRule.d.ts +11 -0
- package/validation/rules/UniqueArgumentDefinitionNamesRule.js +90 -0
- package/validation/rules/UniqueArgumentDefinitionNamesRule.mjs +79 -0
- package/validation/rules/UniqueArgumentNamesRule.d.ts +13 -0
- package/validation/rules/UniqueArgumentNamesRule.js +53 -0
- package/validation/rules/UniqueArgumentNamesRule.mjs +42 -0
- package/validation/rules/UniqueDirectiveNamesRule.d.ts +10 -0
- package/validation/rules/UniqueDirectiveNamesRule.js +50 -0
- package/validation/rules/UniqueDirectiveNamesRule.mjs +43 -0
- package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +16 -0
- package/validation/rules/UniqueDirectivesPerLocationRule.js +93 -0
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs +83 -0
- package/validation/rules/UniqueEnumValueNamesRule.d.ts +10 -0
- package/validation/rules/UniqueEnumValueNamesRule.js +71 -0
- package/validation/rules/UniqueEnumValueNamesRule.mjs +60 -0
- package/validation/rules/UniqueFieldDefinitionNamesRule.d.ts +10 -0
- package/validation/rules/UniqueFieldDefinitionNamesRule.js +83 -0
- package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +75 -0
- package/validation/rules/UniqueFragmentNamesRule.d.ts +12 -0
- package/validation/rules/UniqueFragmentNamesRule.js +39 -0
- package/validation/rules/UniqueFragmentNamesRule.mjs +32 -0
- package/validation/rules/UniqueInputFieldNamesRule.d.ts +13 -0
- package/validation/rules/UniqueInputFieldNamesRule.js +52 -0
- package/validation/rules/UniqueInputFieldNamesRule.mjs +44 -0
- package/validation/rules/UniqueOperationNamesRule.d.ts +12 -0
- package/validation/rules/UniqueOperationNamesRule.js +41 -0
- package/validation/rules/UniqueOperationNamesRule.mjs +34 -0
- package/validation/rules/UniqueOperationTypesRule.d.ts +10 -0
- package/validation/rules/UniqueOperationTypesRule.js +67 -0
- package/validation/rules/UniqueOperationTypesRule.mjs +60 -0
- package/validation/rules/UniqueTypeNamesRule.d.ts +10 -0
- package/validation/rules/UniqueTypeNamesRule.js +53 -0
- package/validation/rules/UniqueTypeNamesRule.mjs +46 -0
- package/validation/rules/UniqueVariableNamesRule.d.ts +10 -0
- package/validation/rules/UniqueVariableNamesRule.js +47 -0
- package/validation/rules/UniqueVariableNamesRule.mjs +39 -0
- package/validation/rules/ValuesOfCorrectTypeRule.d.ts +13 -0
- package/validation/rules/ValuesOfCorrectTypeRule.js +183 -0
- package/validation/rules/ValuesOfCorrectTypeRule.mjs +164 -0
- package/validation/rules/VariablesAreInputTypesRule.d.ts +13 -0
- package/validation/rules/VariablesAreInputTypesRule.js +44 -0
- package/validation/rules/VariablesAreInputTypesRule.mjs +31 -0
- package/validation/rules/VariablesInAllowedPositionRule.d.ts +12 -0
- package/validation/rules/VariablesInAllowedPositionRule.js +114 -0
- package/validation/rules/VariablesInAllowedPositionRule.mjs +95 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +15 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.js +121 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs +107 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +15 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +39 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +30 -0
- package/validation/specifiedRules.d.ts +12 -0
- package/validation/specifiedRules.js +160 -0
- package/validation/specifiedRules.mjs +123 -0
- package/validation/validate.d.ts +61 -0
- package/validation/validate.js +151 -0
- package/validation/validate.mjs +133 -0
- package/version.d.ts +13 -0
- package/version.js +25 -0
- package/version.mjs +17 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.NoDeprecatedCustomRule = NoDeprecatedCustomRule;
|
|
7
|
+
|
|
8
|
+
var _invariant = require('../../../jsutils/invariant.js');
|
|
9
|
+
|
|
10
|
+
var _GraphQLError = require('../../../error/GraphQLError.js');
|
|
11
|
+
|
|
12
|
+
var _definition = require('../../../type/definition.js');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* No deprecated
|
|
16
|
+
*
|
|
17
|
+
* A GraphQL document is only valid if all selected fields and all used enum values have not been
|
|
18
|
+
* deprecated.
|
|
19
|
+
*
|
|
20
|
+
* Note: This rule is optional and is not part of the Validation section of the GraphQL
|
|
21
|
+
* Specification. The main purpose of this rule is detection of deprecated usages and not
|
|
22
|
+
* necessarily to forbid their use when querying a service.
|
|
23
|
+
*/
|
|
24
|
+
function NoDeprecatedCustomRule(context) {
|
|
25
|
+
return {
|
|
26
|
+
Field(node) {
|
|
27
|
+
const fieldDef = context.getFieldDef();
|
|
28
|
+
const deprecationReason =
|
|
29
|
+
fieldDef === null || fieldDef === void 0
|
|
30
|
+
? void 0
|
|
31
|
+
: fieldDef.deprecationReason;
|
|
32
|
+
|
|
33
|
+
if (fieldDef && deprecationReason != null) {
|
|
34
|
+
const parentType = context.getParentType();
|
|
35
|
+
parentType != null || (0, _invariant.invariant)(false);
|
|
36
|
+
context.reportError(
|
|
37
|
+
new _GraphQLError.GraphQLError(
|
|
38
|
+
`The field ${parentType.name}.${fieldDef.name} is deprecated. ${deprecationReason}`,
|
|
39
|
+
node,
|
|
40
|
+
),
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
Argument(node) {
|
|
46
|
+
const argDef = context.getArgument();
|
|
47
|
+
const deprecationReason =
|
|
48
|
+
argDef === null || argDef === void 0
|
|
49
|
+
? void 0
|
|
50
|
+
: argDef.deprecationReason;
|
|
51
|
+
|
|
52
|
+
if (argDef && deprecationReason != null) {
|
|
53
|
+
const directiveDef = context.getDirective();
|
|
54
|
+
|
|
55
|
+
if (directiveDef != null) {
|
|
56
|
+
context.reportError(
|
|
57
|
+
new _GraphQLError.GraphQLError(
|
|
58
|
+
`Directive "@${directiveDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`,
|
|
59
|
+
node,
|
|
60
|
+
),
|
|
61
|
+
);
|
|
62
|
+
} else {
|
|
63
|
+
const parentType = context.getParentType();
|
|
64
|
+
const fieldDef = context.getFieldDef();
|
|
65
|
+
(parentType != null && fieldDef != null) ||
|
|
66
|
+
(0, _invariant.invariant)(false);
|
|
67
|
+
context.reportError(
|
|
68
|
+
new _GraphQLError.GraphQLError(
|
|
69
|
+
`Field "${parentType.name}.${fieldDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`,
|
|
70
|
+
node,
|
|
71
|
+
),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
ObjectField(node) {
|
|
78
|
+
const inputObjectDef = (0, _definition.getNamedType)(
|
|
79
|
+
context.getParentInputType(),
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
if ((0, _definition.isInputObjectType)(inputObjectDef)) {
|
|
83
|
+
const inputFieldDef = inputObjectDef.getFields()[node.name.value];
|
|
84
|
+
const deprecationReason =
|
|
85
|
+
inputFieldDef === null || inputFieldDef === void 0
|
|
86
|
+
? void 0
|
|
87
|
+
: inputFieldDef.deprecationReason;
|
|
88
|
+
|
|
89
|
+
if (deprecationReason != null) {
|
|
90
|
+
context.reportError(
|
|
91
|
+
new _GraphQLError.GraphQLError(
|
|
92
|
+
`The input field ${inputObjectDef.name}.${inputFieldDef.name} is deprecated. ${deprecationReason}`,
|
|
93
|
+
node,
|
|
94
|
+
),
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
EnumValue(node) {
|
|
101
|
+
const enumValueDef = context.getEnumValue();
|
|
102
|
+
const deprecationReason =
|
|
103
|
+
enumValueDef === null || enumValueDef === void 0
|
|
104
|
+
? void 0
|
|
105
|
+
: enumValueDef.deprecationReason;
|
|
106
|
+
|
|
107
|
+
if (enumValueDef && deprecationReason != null) {
|
|
108
|
+
const enumTypeDef = (0, _definition.getNamedType)(
|
|
109
|
+
context.getInputType(),
|
|
110
|
+
);
|
|
111
|
+
enumTypeDef != null || (0, _invariant.invariant)(false);
|
|
112
|
+
context.reportError(
|
|
113
|
+
new _GraphQLError.GraphQLError(
|
|
114
|
+
`The enum value "${enumTypeDef.name}.${enumValueDef.name}" is deprecated. ${deprecationReason}`,
|
|
115
|
+
node,
|
|
116
|
+
),
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { invariant } from '../../../jsutils/invariant.mjs';
|
|
2
|
+
import { GraphQLError } from '../../../error/GraphQLError.mjs';
|
|
3
|
+
import { getNamedType, isInputObjectType } from '../../../type/definition.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* No deprecated
|
|
7
|
+
*
|
|
8
|
+
* A GraphQL document is only valid if all selected fields and all used enum values have not been
|
|
9
|
+
* deprecated.
|
|
10
|
+
*
|
|
11
|
+
* Note: This rule is optional and is not part of the Validation section of the GraphQL
|
|
12
|
+
* Specification. The main purpose of this rule is detection of deprecated usages and not
|
|
13
|
+
* necessarily to forbid their use when querying a service.
|
|
14
|
+
*/
|
|
15
|
+
export function NoDeprecatedCustomRule(context) {
|
|
16
|
+
return {
|
|
17
|
+
Field(node) {
|
|
18
|
+
const fieldDef = context.getFieldDef();
|
|
19
|
+
const deprecationReason =
|
|
20
|
+
fieldDef === null || fieldDef === void 0
|
|
21
|
+
? void 0
|
|
22
|
+
: fieldDef.deprecationReason;
|
|
23
|
+
|
|
24
|
+
if (fieldDef && deprecationReason != null) {
|
|
25
|
+
const parentType = context.getParentType();
|
|
26
|
+
parentType != null || invariant(false);
|
|
27
|
+
context.reportError(
|
|
28
|
+
new GraphQLError(
|
|
29
|
+
`The field ${parentType.name}.${fieldDef.name} is deprecated. ${deprecationReason}`,
|
|
30
|
+
node,
|
|
31
|
+
),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
Argument(node) {
|
|
37
|
+
const argDef = context.getArgument();
|
|
38
|
+
const deprecationReason =
|
|
39
|
+
argDef === null || argDef === void 0
|
|
40
|
+
? void 0
|
|
41
|
+
: argDef.deprecationReason;
|
|
42
|
+
|
|
43
|
+
if (argDef && deprecationReason != null) {
|
|
44
|
+
const directiveDef = context.getDirective();
|
|
45
|
+
|
|
46
|
+
if (directiveDef != null) {
|
|
47
|
+
context.reportError(
|
|
48
|
+
new GraphQLError(
|
|
49
|
+
`Directive "@${directiveDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`,
|
|
50
|
+
node,
|
|
51
|
+
),
|
|
52
|
+
);
|
|
53
|
+
} else {
|
|
54
|
+
const parentType = context.getParentType();
|
|
55
|
+
const fieldDef = context.getFieldDef();
|
|
56
|
+
(parentType != null && fieldDef != null) || invariant(false);
|
|
57
|
+
context.reportError(
|
|
58
|
+
new GraphQLError(
|
|
59
|
+
`Field "${parentType.name}.${fieldDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`,
|
|
60
|
+
node,
|
|
61
|
+
),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
ObjectField(node) {
|
|
68
|
+
const inputObjectDef = getNamedType(context.getParentInputType());
|
|
69
|
+
|
|
70
|
+
if (isInputObjectType(inputObjectDef)) {
|
|
71
|
+
const inputFieldDef = inputObjectDef.getFields()[node.name.value];
|
|
72
|
+
const deprecationReason =
|
|
73
|
+
inputFieldDef === null || inputFieldDef === void 0
|
|
74
|
+
? void 0
|
|
75
|
+
: inputFieldDef.deprecationReason;
|
|
76
|
+
|
|
77
|
+
if (deprecationReason != null) {
|
|
78
|
+
context.reportError(
|
|
79
|
+
new GraphQLError(
|
|
80
|
+
`The input field ${inputObjectDef.name}.${inputFieldDef.name} is deprecated. ${deprecationReason}`,
|
|
81
|
+
node,
|
|
82
|
+
),
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
EnumValue(node) {
|
|
89
|
+
const enumValueDef = context.getEnumValue();
|
|
90
|
+
const deprecationReason =
|
|
91
|
+
enumValueDef === null || enumValueDef === void 0
|
|
92
|
+
? void 0
|
|
93
|
+
: enumValueDef.deprecationReason;
|
|
94
|
+
|
|
95
|
+
if (enumValueDef && deprecationReason != null) {
|
|
96
|
+
const enumTypeDef = getNamedType(context.getInputType());
|
|
97
|
+
enumTypeDef != null || invariant(false);
|
|
98
|
+
context.reportError(
|
|
99
|
+
new GraphQLError(
|
|
100
|
+
`The enum value "${enumTypeDef.name}.${enumValueDef.name}" is deprecated. ${deprecationReason}`,
|
|
101
|
+
node,
|
|
102
|
+
),
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ASTVisitor } from '../../../language/visitor';
|
|
2
|
+
import type { ValidationContext } from '../../ValidationContext';
|
|
3
|
+
/**
|
|
4
|
+
* Prohibit introspection queries
|
|
5
|
+
*
|
|
6
|
+
* A GraphQL document is only valid if all fields selected are not fields that
|
|
7
|
+
* return an introspection type.
|
|
8
|
+
*
|
|
9
|
+
* Note: This rule is optional and is not part of the Validation section of the
|
|
10
|
+
* GraphQL Specification. This rule effectively disables introspection, which
|
|
11
|
+
* does not reflect best practices and should only be done if absolutely necessary.
|
|
12
|
+
*/
|
|
13
|
+
export declare function NoSchemaIntrospectionCustomRule(
|
|
14
|
+
context: ValidationContext,
|
|
15
|
+
): ASTVisitor;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.NoSchemaIntrospectionCustomRule = NoSchemaIntrospectionCustomRule;
|
|
7
|
+
|
|
8
|
+
var _GraphQLError = require('../../../error/GraphQLError.js');
|
|
9
|
+
|
|
10
|
+
var _definition = require('../../../type/definition.js');
|
|
11
|
+
|
|
12
|
+
var _introspection = require('../../../type/introspection.js');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Prohibit introspection queries
|
|
16
|
+
*
|
|
17
|
+
* A GraphQL document is only valid if all fields selected are not fields that
|
|
18
|
+
* return an introspection type.
|
|
19
|
+
*
|
|
20
|
+
* Note: This rule is optional and is not part of the Validation section of the
|
|
21
|
+
* GraphQL Specification. This rule effectively disables introspection, which
|
|
22
|
+
* does not reflect best practices and should only be done if absolutely necessary.
|
|
23
|
+
*/
|
|
24
|
+
function NoSchemaIntrospectionCustomRule(context) {
|
|
25
|
+
return {
|
|
26
|
+
Field(node) {
|
|
27
|
+
const type = (0, _definition.getNamedType)(context.getType());
|
|
28
|
+
|
|
29
|
+
if (type && (0, _introspection.isIntrospectionType)(type)) {
|
|
30
|
+
context.reportError(
|
|
31
|
+
new _GraphQLError.GraphQLError(
|
|
32
|
+
`GraphQL introspection has been disabled, but the requested query contained the field "${node.name.value}".`,
|
|
33
|
+
node,
|
|
34
|
+
),
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { GraphQLError } from '../../../error/GraphQLError.mjs';
|
|
2
|
+
import { getNamedType } from '../../../type/definition.mjs';
|
|
3
|
+
import { isIntrospectionType } from '../../../type/introspection.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Prohibit introspection queries
|
|
7
|
+
*
|
|
8
|
+
* A GraphQL document is only valid if all fields selected are not fields that
|
|
9
|
+
* return an introspection type.
|
|
10
|
+
*
|
|
11
|
+
* Note: This rule is optional and is not part of the Validation section of the
|
|
12
|
+
* GraphQL Specification. This rule effectively disables introspection, which
|
|
13
|
+
* does not reflect best practices and should only be done if absolutely necessary.
|
|
14
|
+
*/
|
|
15
|
+
export function NoSchemaIntrospectionCustomRule(context) {
|
|
16
|
+
return {
|
|
17
|
+
Field(node) {
|
|
18
|
+
const type = getNamedType(context.getType());
|
|
19
|
+
|
|
20
|
+
if (type && isIntrospectionType(type)) {
|
|
21
|
+
context.reportError(
|
|
22
|
+
new GraphQLError(
|
|
23
|
+
`GraphQL introspection has been disabled, but the requested query contained the field "${node.name.value}".`,
|
|
24
|
+
node,
|
|
25
|
+
),
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SDLValidationRule, ValidationRule } from './ValidationContext';
|
|
2
|
+
/**
|
|
3
|
+
* This set includes all validation rules defined by the GraphQL spec.
|
|
4
|
+
*
|
|
5
|
+
* The order of the rules in this list has been adjusted to lead to the
|
|
6
|
+
* most clear output when encountering multiple validation errors.
|
|
7
|
+
*/
|
|
8
|
+
export declare const specifiedRules: ReadonlyArray<ValidationRule>;
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare const specifiedSDLRules: ReadonlyArray<SDLValidationRule>;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.specifiedSDLRules = exports.specifiedRules = void 0;
|
|
7
|
+
|
|
8
|
+
var _ExecutableDefinitionsRule = require('./rules/ExecutableDefinitionsRule.js');
|
|
9
|
+
|
|
10
|
+
var _FieldsOnCorrectTypeRule = require('./rules/FieldsOnCorrectTypeRule.js');
|
|
11
|
+
|
|
12
|
+
var _FragmentsOnCompositeTypesRule = require('./rules/FragmentsOnCompositeTypesRule.js');
|
|
13
|
+
|
|
14
|
+
var _KnownArgumentNamesRule = require('./rules/KnownArgumentNamesRule.js');
|
|
15
|
+
|
|
16
|
+
var _KnownDirectivesRule = require('./rules/KnownDirectivesRule.js');
|
|
17
|
+
|
|
18
|
+
var _KnownFragmentNamesRule = require('./rules/KnownFragmentNamesRule.js');
|
|
19
|
+
|
|
20
|
+
var _KnownTypeNamesRule = require('./rules/KnownTypeNamesRule.js');
|
|
21
|
+
|
|
22
|
+
var _LoneAnonymousOperationRule = require('./rules/LoneAnonymousOperationRule.js');
|
|
23
|
+
|
|
24
|
+
var _LoneSchemaDefinitionRule = require('./rules/LoneSchemaDefinitionRule.js');
|
|
25
|
+
|
|
26
|
+
var _NoFragmentCyclesRule = require('./rules/NoFragmentCyclesRule.js');
|
|
27
|
+
|
|
28
|
+
var _NoUndefinedVariablesRule = require('./rules/NoUndefinedVariablesRule.js');
|
|
29
|
+
|
|
30
|
+
var _NoUnusedFragmentsRule = require('./rules/NoUnusedFragmentsRule.js');
|
|
31
|
+
|
|
32
|
+
var _NoUnusedVariablesRule = require('./rules/NoUnusedVariablesRule.js');
|
|
33
|
+
|
|
34
|
+
var _OverlappingFieldsCanBeMergedRule = require('./rules/OverlappingFieldsCanBeMergedRule.js');
|
|
35
|
+
|
|
36
|
+
var _PossibleFragmentSpreadsRule = require('./rules/PossibleFragmentSpreadsRule.js');
|
|
37
|
+
|
|
38
|
+
var _PossibleTypeExtensionsRule = require('./rules/PossibleTypeExtensionsRule.js');
|
|
39
|
+
|
|
40
|
+
var _ProvidedRequiredArgumentsRule = require('./rules/ProvidedRequiredArgumentsRule.js');
|
|
41
|
+
|
|
42
|
+
var _ScalarLeafsRule = require('./rules/ScalarLeafsRule.js');
|
|
43
|
+
|
|
44
|
+
var _SingleFieldSubscriptionsRule = require('./rules/SingleFieldSubscriptionsRule.js');
|
|
45
|
+
|
|
46
|
+
var _UniqueArgumentDefinitionNamesRule = require('./rules/UniqueArgumentDefinitionNamesRule.js');
|
|
47
|
+
|
|
48
|
+
var _UniqueArgumentNamesRule = require('./rules/UniqueArgumentNamesRule.js');
|
|
49
|
+
|
|
50
|
+
var _UniqueDirectiveNamesRule = require('./rules/UniqueDirectiveNamesRule.js');
|
|
51
|
+
|
|
52
|
+
var _UniqueDirectivesPerLocationRule = require('./rules/UniqueDirectivesPerLocationRule.js');
|
|
53
|
+
|
|
54
|
+
var _UniqueEnumValueNamesRule = require('./rules/UniqueEnumValueNamesRule.js');
|
|
55
|
+
|
|
56
|
+
var _UniqueFieldDefinitionNamesRule = require('./rules/UniqueFieldDefinitionNamesRule.js');
|
|
57
|
+
|
|
58
|
+
var _UniqueFragmentNamesRule = require('./rules/UniqueFragmentNamesRule.js');
|
|
59
|
+
|
|
60
|
+
var _UniqueInputFieldNamesRule = require('./rules/UniqueInputFieldNamesRule.js');
|
|
61
|
+
|
|
62
|
+
var _UniqueOperationNamesRule = require('./rules/UniqueOperationNamesRule.js');
|
|
63
|
+
|
|
64
|
+
var _UniqueOperationTypesRule = require('./rules/UniqueOperationTypesRule.js');
|
|
65
|
+
|
|
66
|
+
var _UniqueTypeNamesRule = require('./rules/UniqueTypeNamesRule.js');
|
|
67
|
+
|
|
68
|
+
var _UniqueVariableNamesRule = require('./rules/UniqueVariableNamesRule.js');
|
|
69
|
+
|
|
70
|
+
var _ValuesOfCorrectTypeRule = require('./rules/ValuesOfCorrectTypeRule.js');
|
|
71
|
+
|
|
72
|
+
var _VariablesAreInputTypesRule = require('./rules/VariablesAreInputTypesRule.js');
|
|
73
|
+
|
|
74
|
+
var _VariablesInAllowedPositionRule = require('./rules/VariablesInAllowedPositionRule.js');
|
|
75
|
+
|
|
76
|
+
// Spec Section: "Executable Definitions"
|
|
77
|
+
// Spec Section: "Field Selections on Objects, Interfaces, and Unions Types"
|
|
78
|
+
// Spec Section: "Fragments on Composite Types"
|
|
79
|
+
// Spec Section: "Argument Names"
|
|
80
|
+
// Spec Section: "Directives Are Defined"
|
|
81
|
+
// Spec Section: "Fragment spread target defined"
|
|
82
|
+
// Spec Section: "Fragment Spread Type Existence"
|
|
83
|
+
// Spec Section: "Lone Anonymous Operation"
|
|
84
|
+
// SDL-specific validation rules
|
|
85
|
+
// Spec Section: "Fragments must not form cycles"
|
|
86
|
+
// Spec Section: "All Variable Used Defined"
|
|
87
|
+
// Spec Section: "Fragments must be used"
|
|
88
|
+
// Spec Section: "All Variables Used"
|
|
89
|
+
// Spec Section: "Field Selection Merging"
|
|
90
|
+
// Spec Section: "Fragment spread is possible"
|
|
91
|
+
// Spec Section: "Argument Optionality"
|
|
92
|
+
// Spec Section: "Leaf Field Selections"
|
|
93
|
+
// Spec Section: "Subscriptions with Single Root Field"
|
|
94
|
+
// Spec Section: "Argument Uniqueness"
|
|
95
|
+
// Spec Section: "Directives Are Unique Per Location"
|
|
96
|
+
// Spec Section: "Fragment Name Uniqueness"
|
|
97
|
+
// Spec Section: "Input Object Field Uniqueness"
|
|
98
|
+
// Spec Section: "Operation Name Uniqueness"
|
|
99
|
+
// Spec Section: "Variable Uniqueness"
|
|
100
|
+
// Spec Section: "Value Type Correctness"
|
|
101
|
+
// Spec Section: "Variables are Input Types"
|
|
102
|
+
// Spec Section: "All Variable Usages Are Allowed"
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* This set includes all validation rules defined by the GraphQL spec.
|
|
106
|
+
*
|
|
107
|
+
* The order of the rules in this list has been adjusted to lead to the
|
|
108
|
+
* most clear output when encountering multiple validation errors.
|
|
109
|
+
*/
|
|
110
|
+
const specifiedRules = Object.freeze([
|
|
111
|
+
_ExecutableDefinitionsRule.ExecutableDefinitionsRule,
|
|
112
|
+
_UniqueOperationNamesRule.UniqueOperationNamesRule,
|
|
113
|
+
_LoneAnonymousOperationRule.LoneAnonymousOperationRule,
|
|
114
|
+
_SingleFieldSubscriptionsRule.SingleFieldSubscriptionsRule,
|
|
115
|
+
_KnownTypeNamesRule.KnownTypeNamesRule,
|
|
116
|
+
_FragmentsOnCompositeTypesRule.FragmentsOnCompositeTypesRule,
|
|
117
|
+
_VariablesAreInputTypesRule.VariablesAreInputTypesRule,
|
|
118
|
+
_ScalarLeafsRule.ScalarLeafsRule,
|
|
119
|
+
_FieldsOnCorrectTypeRule.FieldsOnCorrectTypeRule,
|
|
120
|
+
_UniqueFragmentNamesRule.UniqueFragmentNamesRule,
|
|
121
|
+
_KnownFragmentNamesRule.KnownFragmentNamesRule,
|
|
122
|
+
_NoUnusedFragmentsRule.NoUnusedFragmentsRule,
|
|
123
|
+
_PossibleFragmentSpreadsRule.PossibleFragmentSpreadsRule,
|
|
124
|
+
_NoFragmentCyclesRule.NoFragmentCyclesRule,
|
|
125
|
+
_UniqueVariableNamesRule.UniqueVariableNamesRule,
|
|
126
|
+
_NoUndefinedVariablesRule.NoUndefinedVariablesRule,
|
|
127
|
+
_NoUnusedVariablesRule.NoUnusedVariablesRule,
|
|
128
|
+
_KnownDirectivesRule.KnownDirectivesRule,
|
|
129
|
+
_UniqueDirectivesPerLocationRule.UniqueDirectivesPerLocationRule,
|
|
130
|
+
_KnownArgumentNamesRule.KnownArgumentNamesRule,
|
|
131
|
+
_UniqueArgumentNamesRule.UniqueArgumentNamesRule,
|
|
132
|
+
_ValuesOfCorrectTypeRule.ValuesOfCorrectTypeRule,
|
|
133
|
+
_ProvidedRequiredArgumentsRule.ProvidedRequiredArgumentsRule,
|
|
134
|
+
_VariablesInAllowedPositionRule.VariablesInAllowedPositionRule,
|
|
135
|
+
_OverlappingFieldsCanBeMergedRule.OverlappingFieldsCanBeMergedRule,
|
|
136
|
+
_UniqueInputFieldNamesRule.UniqueInputFieldNamesRule,
|
|
137
|
+
]);
|
|
138
|
+
/**
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
|
|
142
|
+
exports.specifiedRules = specifiedRules;
|
|
143
|
+
const specifiedSDLRules = Object.freeze([
|
|
144
|
+
_LoneSchemaDefinitionRule.LoneSchemaDefinitionRule,
|
|
145
|
+
_UniqueOperationTypesRule.UniqueOperationTypesRule,
|
|
146
|
+
_UniqueTypeNamesRule.UniqueTypeNamesRule,
|
|
147
|
+
_UniqueEnumValueNamesRule.UniqueEnumValueNamesRule,
|
|
148
|
+
_UniqueFieldDefinitionNamesRule.UniqueFieldDefinitionNamesRule,
|
|
149
|
+
_UniqueArgumentDefinitionNamesRule.UniqueArgumentDefinitionNamesRule,
|
|
150
|
+
_UniqueDirectiveNamesRule.UniqueDirectiveNamesRule,
|
|
151
|
+
_KnownTypeNamesRule.KnownTypeNamesRule,
|
|
152
|
+
_KnownDirectivesRule.KnownDirectivesRule,
|
|
153
|
+
_UniqueDirectivesPerLocationRule.UniqueDirectivesPerLocationRule,
|
|
154
|
+
_PossibleTypeExtensionsRule.PossibleTypeExtensionsRule,
|
|
155
|
+
_KnownArgumentNamesRule.KnownArgumentNamesOnDirectivesRule,
|
|
156
|
+
_UniqueArgumentNamesRule.UniqueArgumentNamesRule,
|
|
157
|
+
_UniqueInputFieldNamesRule.UniqueInputFieldNamesRule,
|
|
158
|
+
_ProvidedRequiredArgumentsRule.ProvidedRequiredArgumentsOnDirectivesRule,
|
|
159
|
+
]);
|
|
160
|
+
exports.specifiedSDLRules = specifiedSDLRules;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// Spec Section: "Executable Definitions"
|
|
2
|
+
import { ExecutableDefinitionsRule } from './rules/ExecutableDefinitionsRule.mjs'; // Spec Section: "Field Selections on Objects, Interfaces, and Unions Types"
|
|
3
|
+
|
|
4
|
+
import { FieldsOnCorrectTypeRule } from './rules/FieldsOnCorrectTypeRule.mjs'; // Spec Section: "Fragments on Composite Types"
|
|
5
|
+
|
|
6
|
+
import { FragmentsOnCompositeTypesRule } from './rules/FragmentsOnCompositeTypesRule.mjs'; // Spec Section: "Argument Names"
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
KnownArgumentNamesOnDirectivesRule,
|
|
10
|
+
KnownArgumentNamesRule,
|
|
11
|
+
} from './rules/KnownArgumentNamesRule.mjs'; // Spec Section: "Directives Are Defined"
|
|
12
|
+
|
|
13
|
+
import { KnownDirectivesRule } from './rules/KnownDirectivesRule.mjs'; // Spec Section: "Fragment spread target defined"
|
|
14
|
+
|
|
15
|
+
import { KnownFragmentNamesRule } from './rules/KnownFragmentNamesRule.mjs'; // Spec Section: "Fragment Spread Type Existence"
|
|
16
|
+
|
|
17
|
+
import { KnownTypeNamesRule } from './rules/KnownTypeNamesRule.mjs'; // Spec Section: "Lone Anonymous Operation"
|
|
18
|
+
|
|
19
|
+
import { LoneAnonymousOperationRule } from './rules/LoneAnonymousOperationRule.mjs'; // SDL-specific validation rules
|
|
20
|
+
|
|
21
|
+
import { LoneSchemaDefinitionRule } from './rules/LoneSchemaDefinitionRule.mjs'; // Spec Section: "Fragments must not form cycles"
|
|
22
|
+
|
|
23
|
+
import { NoFragmentCyclesRule } from './rules/NoFragmentCyclesRule.mjs'; // Spec Section: "All Variable Used Defined"
|
|
24
|
+
|
|
25
|
+
import { NoUndefinedVariablesRule } from './rules/NoUndefinedVariablesRule.mjs'; // Spec Section: "Fragments must be used"
|
|
26
|
+
|
|
27
|
+
import { NoUnusedFragmentsRule } from './rules/NoUnusedFragmentsRule.mjs'; // Spec Section: "All Variables Used"
|
|
28
|
+
|
|
29
|
+
import { NoUnusedVariablesRule } from './rules/NoUnusedVariablesRule.mjs'; // Spec Section: "Field Selection Merging"
|
|
30
|
+
|
|
31
|
+
import { OverlappingFieldsCanBeMergedRule } from './rules/OverlappingFieldsCanBeMergedRule.mjs'; // Spec Section: "Fragment spread is possible"
|
|
32
|
+
|
|
33
|
+
import { PossibleFragmentSpreadsRule } from './rules/PossibleFragmentSpreadsRule.mjs';
|
|
34
|
+
import { PossibleTypeExtensionsRule } from './rules/PossibleTypeExtensionsRule.mjs'; // Spec Section: "Argument Optionality"
|
|
35
|
+
|
|
36
|
+
import {
|
|
37
|
+
ProvidedRequiredArgumentsOnDirectivesRule,
|
|
38
|
+
ProvidedRequiredArgumentsRule,
|
|
39
|
+
} from './rules/ProvidedRequiredArgumentsRule.mjs'; // Spec Section: "Leaf Field Selections"
|
|
40
|
+
|
|
41
|
+
import { ScalarLeafsRule } from './rules/ScalarLeafsRule.mjs'; // Spec Section: "Subscriptions with Single Root Field"
|
|
42
|
+
|
|
43
|
+
import { SingleFieldSubscriptionsRule } from './rules/SingleFieldSubscriptionsRule.mjs';
|
|
44
|
+
import { UniqueArgumentDefinitionNamesRule } from './rules/UniqueArgumentDefinitionNamesRule.mjs'; // Spec Section: "Argument Uniqueness"
|
|
45
|
+
|
|
46
|
+
import { UniqueArgumentNamesRule } from './rules/UniqueArgumentNamesRule.mjs';
|
|
47
|
+
import { UniqueDirectiveNamesRule } from './rules/UniqueDirectiveNamesRule.mjs'; // Spec Section: "Directives Are Unique Per Location"
|
|
48
|
+
|
|
49
|
+
import { UniqueDirectivesPerLocationRule } from './rules/UniqueDirectivesPerLocationRule.mjs';
|
|
50
|
+
import { UniqueEnumValueNamesRule } from './rules/UniqueEnumValueNamesRule.mjs';
|
|
51
|
+
import { UniqueFieldDefinitionNamesRule } from './rules/UniqueFieldDefinitionNamesRule.mjs'; // Spec Section: "Fragment Name Uniqueness"
|
|
52
|
+
|
|
53
|
+
import { UniqueFragmentNamesRule } from './rules/UniqueFragmentNamesRule.mjs'; // Spec Section: "Input Object Field Uniqueness"
|
|
54
|
+
|
|
55
|
+
import { UniqueInputFieldNamesRule } from './rules/UniqueInputFieldNamesRule.mjs'; // Spec Section: "Operation Name Uniqueness"
|
|
56
|
+
|
|
57
|
+
import { UniqueOperationNamesRule } from './rules/UniqueOperationNamesRule.mjs';
|
|
58
|
+
import { UniqueOperationTypesRule } from './rules/UniqueOperationTypesRule.mjs';
|
|
59
|
+
import { UniqueTypeNamesRule } from './rules/UniqueTypeNamesRule.mjs'; // Spec Section: "Variable Uniqueness"
|
|
60
|
+
|
|
61
|
+
import { UniqueVariableNamesRule } from './rules/UniqueVariableNamesRule.mjs'; // Spec Section: "Value Type Correctness"
|
|
62
|
+
|
|
63
|
+
import { ValuesOfCorrectTypeRule } from './rules/ValuesOfCorrectTypeRule.mjs'; // Spec Section: "Variables are Input Types"
|
|
64
|
+
|
|
65
|
+
import { VariablesAreInputTypesRule } from './rules/VariablesAreInputTypesRule.mjs'; // Spec Section: "All Variable Usages Are Allowed"
|
|
66
|
+
|
|
67
|
+
import { VariablesInAllowedPositionRule } from './rules/VariablesInAllowedPositionRule.mjs';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* This set includes all validation rules defined by the GraphQL spec.
|
|
71
|
+
*
|
|
72
|
+
* The order of the rules in this list has been adjusted to lead to the
|
|
73
|
+
* most clear output when encountering multiple validation errors.
|
|
74
|
+
*/
|
|
75
|
+
export const specifiedRules = Object.freeze([
|
|
76
|
+
ExecutableDefinitionsRule,
|
|
77
|
+
UniqueOperationNamesRule,
|
|
78
|
+
LoneAnonymousOperationRule,
|
|
79
|
+
SingleFieldSubscriptionsRule,
|
|
80
|
+
KnownTypeNamesRule,
|
|
81
|
+
FragmentsOnCompositeTypesRule,
|
|
82
|
+
VariablesAreInputTypesRule,
|
|
83
|
+
ScalarLeafsRule,
|
|
84
|
+
FieldsOnCorrectTypeRule,
|
|
85
|
+
UniqueFragmentNamesRule,
|
|
86
|
+
KnownFragmentNamesRule,
|
|
87
|
+
NoUnusedFragmentsRule,
|
|
88
|
+
PossibleFragmentSpreadsRule,
|
|
89
|
+
NoFragmentCyclesRule,
|
|
90
|
+
UniqueVariableNamesRule,
|
|
91
|
+
NoUndefinedVariablesRule,
|
|
92
|
+
NoUnusedVariablesRule,
|
|
93
|
+
KnownDirectivesRule,
|
|
94
|
+
UniqueDirectivesPerLocationRule,
|
|
95
|
+
KnownArgumentNamesRule,
|
|
96
|
+
UniqueArgumentNamesRule,
|
|
97
|
+
ValuesOfCorrectTypeRule,
|
|
98
|
+
ProvidedRequiredArgumentsRule,
|
|
99
|
+
VariablesInAllowedPositionRule,
|
|
100
|
+
OverlappingFieldsCanBeMergedRule,
|
|
101
|
+
UniqueInputFieldNamesRule,
|
|
102
|
+
]);
|
|
103
|
+
/**
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
export const specifiedSDLRules = Object.freeze([
|
|
108
|
+
LoneSchemaDefinitionRule,
|
|
109
|
+
UniqueOperationTypesRule,
|
|
110
|
+
UniqueTypeNamesRule,
|
|
111
|
+
UniqueEnumValueNamesRule,
|
|
112
|
+
UniqueFieldDefinitionNamesRule,
|
|
113
|
+
UniqueArgumentDefinitionNamesRule,
|
|
114
|
+
UniqueDirectiveNamesRule,
|
|
115
|
+
KnownTypeNamesRule,
|
|
116
|
+
KnownDirectivesRule,
|
|
117
|
+
UniqueDirectivesPerLocationRule,
|
|
118
|
+
PossibleTypeExtensionsRule,
|
|
119
|
+
KnownArgumentNamesOnDirectivesRule,
|
|
120
|
+
UniqueArgumentNamesRule,
|
|
121
|
+
UniqueInputFieldNamesRule,
|
|
122
|
+
ProvidedRequiredArgumentsOnDirectivesRule,
|
|
123
|
+
]);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Maybe } from '../jsutils/Maybe';
|
|
2
|
+
import { GraphQLError } from '../error/GraphQLError';
|
|
3
|
+
import type { DocumentNode } from '../language/ast';
|
|
4
|
+
import type { GraphQLSchema } from '../type/schema';
|
|
5
|
+
import { TypeInfo } from '../utilities/TypeInfo';
|
|
6
|
+
import type { SDLValidationRule, ValidationRule } from './ValidationContext';
|
|
7
|
+
/**
|
|
8
|
+
* Implements the "Validation" section of the spec.
|
|
9
|
+
*
|
|
10
|
+
* Validation runs synchronously, returning an array of encountered errors, or
|
|
11
|
+
* an empty array if no errors were encountered and the document is valid.
|
|
12
|
+
*
|
|
13
|
+
* A list of specific validation rules may be provided. If not provided, the
|
|
14
|
+
* default list of rules defined by the GraphQL specification will be used.
|
|
15
|
+
*
|
|
16
|
+
* Each validation rules is a function which returns a visitor
|
|
17
|
+
* (see the language/visitor API). Visitor methods are expected to return
|
|
18
|
+
* GraphQLErrors, or Arrays of GraphQLErrors when invalid.
|
|
19
|
+
*
|
|
20
|
+
* Validate will stop validation after a `maxErrors` limit has been reached.
|
|
21
|
+
* Attackers can send pathologically invalid queries to induce a DoS attack,
|
|
22
|
+
* so by default `maxErrors` set to 100 errors.
|
|
23
|
+
*
|
|
24
|
+
* Optionally a custom TypeInfo instance may be provided. If not provided, one
|
|
25
|
+
* will be created from the provided schema.
|
|
26
|
+
*/
|
|
27
|
+
export declare function validate(
|
|
28
|
+
schema: GraphQLSchema,
|
|
29
|
+
documentAST: DocumentNode,
|
|
30
|
+
rules?: ReadonlyArray<ValidationRule>,
|
|
31
|
+
options?: {
|
|
32
|
+
maxErrors?: number;
|
|
33
|
+
},
|
|
34
|
+
/** @deprecated will be removed in 17.0.0 */
|
|
35
|
+
typeInfo?: TypeInfo,
|
|
36
|
+
): ReadonlyArray<GraphQLError>;
|
|
37
|
+
/**
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
export declare function validateSDL(
|
|
41
|
+
documentAST: DocumentNode,
|
|
42
|
+
schemaToExtend?: Maybe<GraphQLSchema>,
|
|
43
|
+
rules?: ReadonlyArray<SDLValidationRule>,
|
|
44
|
+
): ReadonlyArray<GraphQLError>;
|
|
45
|
+
/**
|
|
46
|
+
* Utility function which asserts a SDL document is valid by throwing an error
|
|
47
|
+
* if it is invalid.
|
|
48
|
+
*
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
export declare function assertValidSDL(documentAST: DocumentNode): void;
|
|
52
|
+
/**
|
|
53
|
+
* Utility function which asserts a SDL document is valid by throwing an error
|
|
54
|
+
* if it is invalid.
|
|
55
|
+
*
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
export declare function assertValidSDLExtension(
|
|
59
|
+
documentAST: DocumentNode,
|
|
60
|
+
schema: GraphQLSchema,
|
|
61
|
+
): void;
|