From 0304b872a2a69e8be99ea8a724b979311abb00a0 Mon Sep 17 00:00:00 2001 From: Firede Date: Sat, 16 Jun 2018 16:34:20 +0800 Subject: [PATCH] update to graphql v14.0.0 (WIP) GraphQL.js v14.0.0 has not been released yet, this commit is sync to https://github.com/graphql/graphql-js/commit/9b7807a8ff20c6f2565577af8d90530acc49230d --- types/graphql/error/GraphQLError.d.ts | 2 +- types/graphql/error/formatError.d.ts | 3 +- types/graphql/error/locatedError.d.ts | 2 +- types/graphql/execution/execute.d.ts | 5 -- types/graphql/index.d.ts | 22 +++++--- types/graphql/language/ast.d.ts | 51 +++++++++++-------- types/graphql/language/index.d.ts | 11 +++- types/graphql/language/kinds.d.ts | 9 ++-- types/graphql/language/parser.d.ts | 4 +- types/graphql/language/visitor.d.ts | 4 +- types/graphql/type/definition.d.ts | 16 +++++- types/graphql/type/schema.d.ts | 4 +- types/graphql/utilities/buildASTSchema.d.ts | 8 ++- .../utilities/getOperationRootType.d.ts | 11 ++++ types/graphql/utilities/index.d.ts | 9 ++-- .../graphql/utilities/introspectionQuery.d.ts | 5 ++ types/graphql/utilities/isValidJSValue.d.ts | 2 + .../utilities/isValidLiteralValue.d.ts | 2 + types/graphql/validation/index.d.ts | 5 +- .../rules/FragmentsOnCompositeTypes.d.ts | 5 +- .../rules/PossibleFragmentSpreads.d.ts | 5 +- .../rules/ProvidedNonNullArguments.d.ts | 15 ------ .../rules/ProvidedRequiredArguments.d.ts | 14 +++++ .../graphql/validation/rules/ScalarLeafs.d.ts | 5 +- .../rules/VariablesDefaultValueAllowed.d.ts | 13 ----- .../rules/VariablesInAllowedPosition.d.ts | 3 +- types/graphql/validation/specifiedRules.d.ts | 5 +- 27 files changed, 140 insertions(+), 100 deletions(-) create mode 100644 types/graphql/utilities/getOperationRootType.d.ts delete mode 100644 types/graphql/validation/rules/ProvidedNonNullArguments.d.ts create mode 100644 types/graphql/validation/rules/ProvidedRequiredArguments.d.ts delete mode 100644 types/graphql/validation/rules/VariablesDefaultValueAllowed.d.ts diff --git a/types/graphql/error/GraphQLError.d.ts b/types/graphql/error/GraphQLError.d.ts index ce31564fb1..9a649a5c99 100644 --- a/types/graphql/error/GraphQLError.d.ts +++ b/types/graphql/error/GraphQLError.d.ts @@ -64,7 +64,7 @@ export class GraphQLError extends Error { /** * Extension fields to add to the formatted error. */ - readonly extensions: { [key: string]: any } | void; + readonly extensions: { [key: string]: any } | undefined; constructor( message: string, diff --git a/types/graphql/error/formatError.d.ts b/types/graphql/error/formatError.d.ts index 7f13117cf0..2d87c877a9 100644 --- a/types/graphql/error/formatError.d.ts +++ b/types/graphql/error/formatError.d.ts @@ -11,6 +11,5 @@ export interface GraphQLFormattedError { readonly message: string; readonly locations: ReadonlyArray | undefined; readonly path: ReadonlyArray | undefined; - // Extensions - readonly [key: string]: any; + readonly extensions?: { [key: string]: any }; } diff --git a/types/graphql/error/locatedError.d.ts b/types/graphql/error/locatedError.d.ts index 77dd470c63..0d49d5f3a3 100644 --- a/types/graphql/error/locatedError.d.ts +++ b/types/graphql/error/locatedError.d.ts @@ -7,7 +7,7 @@ import { ASTNode } from "../language/ast"; * document responsible for the original Error. */ export function locatedError( - originalError: Error, + originalError: Error | GraphQLError, nodes: ReadonlyArray, path: ReadonlyArray ): GraphQLError; diff --git a/types/graphql/execution/execute.d.ts b/types/graphql/execution/execute.d.ts index 7ef4d5ce63..1b0eccbd92 100644 --- a/types/graphql/execution/execute.d.ts +++ b/types/graphql/execution/execute.d.ts @@ -121,11 +121,6 @@ export function buildExecutionContext( fieldResolver: Maybe> ): ReadonlyArray | ExecutionContext; -/** - * Extracts the root type of the operation from the schema. - */ -export function getOperationRootType(schema: GraphQLSchema, operation: OperationDefinitionNode): GraphQLObjectType; - /** * Given a selectionSet, adds all of the fields in that selection to * the passed in map of fields, and returns it at the end. diff --git a/types/graphql/index.d.ts b/types/graphql/index.d.ts index ba9213b7c4..c4a425a541 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -226,9 +226,16 @@ export { EnumTypeDefinitionNode, EnumValueDefinitionNode, InputObjectTypeDefinitionNode, - TypeExtensionNode, - ObjectTypeExtensionNode, DirectiveDefinitionNode, + TypeSystemExtensionNode, + SchemaExtensionNode, + TypeExtensionNode, + ScalarTypeExtensionNode, + ObjectTypeExtensionNode, + InterfaceTypeExtensionNode, + UnionTypeExtensionNode, + EnumTypeExtensionNode, + InputObjectTypeExtensionNode, KindEnum, TokenKindEnum, DirectiveLocationEnum, @@ -267,7 +274,7 @@ export { NoUnusedVariablesRule, OverlappingFieldsCanBeMergedRule, PossibleFragmentSpreadsRule, - ProvidedNonNullArgumentsRule, + ProvidedRequiredArgumentsRule, ScalarLeafsRule, SingleFieldSubscriptionsRule, UniqueArgumentNamesRule, @@ -278,7 +285,6 @@ export { UniqueVariableNamesRule, ValuesOfCorrectTypeRule, VariablesAreInputTypesRule, - VariablesDefaultValueAllowedRule, VariablesInAllowedPositionRule, } from "./validation"; @@ -290,10 +296,12 @@ export { // Produce the GraphQL query recommended for a full schema introspection. // Accepts optional IntrospectionOptions. getIntrospectionQuery, - // Deprecated: use getIntrospectionQuery + // @deprecated: use getIntrospectionQuery - will be removed in v15 introspectionQuery, // Gets the target Operation from a Document getOperationAST, + // Gets the Type for the target Operation AST. + getOperationRootType, // Convert a GraphQLSchema to an IntrospectionQuery introspectionFromSchema, // Build a GraphQLSchema from an introspection result. @@ -329,9 +337,9 @@ export { TypeInfo, // Coerces a JavaScript value to a GraphQL type, or produces errors. coerceValue, - // @deprecated use coerceValue + // @deprecated use coerceValue - will be removed in v15 isValidJSValue, - // Determine if AST values adhere to a GraphQL type. + // @deprecated use validation - will be removed in v15 isValidLiteralValue, // Concatenates multiple AST together. concatAST, diff --git a/types/graphql/language/ast.d.ts b/types/graphql/language/ast.d.ts index 21601385ff..0a23cb68ee 100644 --- a/types/graphql/language/ast.d.ts +++ b/types/graphql/language/ast.d.ts @@ -115,13 +115,14 @@ export type ASTNode = | EnumTypeDefinitionNode | EnumValueDefinitionNode | InputObjectTypeDefinitionNode + | DirectiveDefinitionNode + | SchemaExtensionNode | ScalarTypeExtensionNode | ObjectTypeExtensionNode | InterfaceTypeExtensionNode | UnionTypeExtensionNode | EnumTypeExtensionNode - | InputObjectTypeExtensionNode - | DirectiveDefinitionNode; + | InputObjectTypeExtensionNode; /** * Utility type listing all nodes indexed by their kind. @@ -162,13 +163,14 @@ export interface ASTKindToNode { EnumTypeDefinition: EnumTypeDefinitionNode; EnumValueDefinition: EnumValueDefinitionNode; InputObjectTypeDefinition: InputObjectTypeDefinitionNode; + DirectiveDefinition: DirectiveDefinitionNode; + SchemaExtension: SchemaExtensionNode; ScalarTypeExtension: ScalarTypeExtensionNode; ObjectTypeExtension: ObjectTypeExtensionNode; InterfaceTypeExtension: InterfaceTypeExtensionNode; UnionTypeExtension: UnionTypeExtensionNode; EnumTypeExtension: EnumTypeExtensionNode; InputObjectTypeExtension: InputObjectTypeExtensionNode; - DirectiveDefinition: DirectiveDefinitionNode; } // Name @@ -187,7 +189,7 @@ export interface DocumentNode { readonly definitions: ReadonlyArray; } -export type DefinitionNode = ExecutableDefinitionNode | TypeSystemDefinitionNode; // experimental non-spec addition. +export type DefinitionNode = ExecutableDefinitionNode | TypeSystemDefinitionNode | TypeSystemExtensionNode; export type ExecutableDefinitionNode = OperationDefinitionNode | FragmentDefinitionNode; @@ -372,16 +374,12 @@ export interface NonNullTypeNode { // Type System Definition -export type TypeSystemDefinitionNode = - | SchemaDefinitionNode - | TypeDefinitionNode - | TypeExtensionNode - | DirectiveDefinitionNode; +export type TypeSystemDefinitionNode = SchemaDefinitionNode | TypeDefinitionNode | DirectiveDefinitionNode; export interface SchemaDefinitionNode { readonly kind: "SchemaDefinition"; readonly loc?: Location; - readonly directives: ReadonlyArray; + readonly directives?: ReadonlyArray; readonly operationTypes: ReadonlyArray; } @@ -484,6 +482,28 @@ export interface InputObjectTypeDefinitionNode { readonly fields?: ReadonlyArray; } +// Directive Definitions + +export interface DirectiveDefinitionNode { + readonly kind: "DirectiveDefinition"; + readonly loc?: Location; + readonly description?: StringValueNode; + readonly name: NameNode; + readonly arguments?: ReadonlyArray; + readonly locations: ReadonlyArray; +} + +// Type System Extensions + +export type TypeSystemExtensionNode = SchemaExtensionNode | TypeExtensionNode; + +export type SchemaExtensionNode = { + readonly kind: "SchemaExtension"; + readonly loc?: Location; + readonly directives?: ReadonlyArray; + readonly operationTypes?: ReadonlyArray; +}; + // Type Extensions export type TypeExtensionNode = @@ -541,14 +561,3 @@ export interface InputObjectTypeExtensionNode { readonly directives?: ReadonlyArray; readonly fields?: ReadonlyArray; } - -// Directive Definitions - -export interface DirectiveDefinitionNode { - readonly kind: "DirectiveDefinition"; - readonly loc?: Location; - readonly description?: StringValueNode; - readonly name: NameNode; - readonly arguments?: ReadonlyArray; - readonly locations: ReadonlyArray; -} diff --git a/types/graphql/language/index.d.ts b/types/graphql/language/index.d.ts index e36dcbbb91..b603240d1c 100644 --- a/types/graphql/language/index.d.ts +++ b/types/graphql/language/index.d.ts @@ -66,9 +66,16 @@ export { EnumTypeDefinitionNode, EnumValueDefinitionNode, InputObjectTypeDefinitionNode, - TypeExtensionNode, - ObjectTypeExtensionNode, DirectiveDefinitionNode, + TypeSystemExtensionNode, + SchemaExtensionNode, + TypeExtensionNode, + ScalarTypeExtensionNode, + ObjectTypeExtensionNode, + InterfaceTypeExtensionNode, + UnionTypeExtensionNode, + EnumTypeExtensionNode, + InputObjectTypeExtensionNode, } from "./ast"; export { DirectiveLocation, DirectiveLocationEnum } from "./directiveLocation"; diff --git a/types/graphql/language/kinds.d.ts b/types/graphql/language/kinds.d.ts index 768f00addd..e22bde2521 100644 --- a/types/graphql/language/kinds.d.ts +++ b/types/graphql/language/kinds.d.ts @@ -56,6 +56,12 @@ type _Kind = { ENUM_VALUE_DEFINITION: "EnumValueDefinition"; INPUT_OBJECT_TYPE_DEFINITION: "InputObjectTypeDefinition"; + // Directive Definitions + DIRECTIVE_DEFINITION: "DirectiveDefinition"; + + // Type System Extensions + SCHEMA_EXTENSION: "SchemaExtension"; + // Type Extensions SCALAR_TYPE_EXTENSION: "ScalarTypeExtension"; OBJECT_TYPE_EXTENSION: "ObjectTypeExtension"; @@ -63,9 +69,6 @@ type _Kind = { UNION_TYPE_EXTENSION: "UnionTypeExtension"; ENUM_TYPE_EXTENSION: "EnumTypeExtension"; INPUT_OBJECT_TYPE_EXTENSION: "InputObjectTypeExtension"; - - // Directive Definitions - DIRECTIVE_DEFINITION: "DirectiveDefinition"; }; /** diff --git a/types/graphql/language/parser.d.ts b/types/graphql/language/parser.d.ts index b07db1ff38..cc9b0fd75f 100644 --- a/types/graphql/language/parser.d.ts +++ b/types/graphql/language/parser.d.ts @@ -19,7 +19,7 @@ export interface ParseOptions { * specification. * * This option is provided to ease adoption of the final SDL specification - * and will be removed in a future major release. + * and will be removed in v16. */ allowLegacySDLEmptyFields?: boolean; @@ -29,7 +29,7 @@ export interface ParseOptions { * current specification. * * This option is provided to ease adoption of the final SDL specification - * and will be removed in a future major release. + * and will be removed in v16. */ allowLegacySDLImplementsInterfaces?: boolean; diff --git a/types/graphql/language/visitor.d.ts b/types/graphql/language/visitor.d.ts index be50e6e02e..26de8a9699 100644 --- a/types/graphql/language/visitor.d.ts +++ b/types/graphql/language/visitor.d.ts @@ -33,9 +33,9 @@ export type VisitFn = ( parent: TAnyNode | ReadonlyArray | undefined, // The key path to get to this node from the root node. path: ReadonlyArray, - // All nodes and Arrays visited before reaching this node. + // All nodes and Arrays visited before reaching parent of this node. // These correspond to array indices in `path`. - // Note: ancestors includes arrays which contain the visited node. + // Note: ancestors includes arrays which contain the parent of visited node. ancestors: ReadonlyArray> ) => any; diff --git a/types/graphql/type/definition.d.ts b/types/graphql/type/definition.d.ts index b078acccb1..afb19eb7d2 100644 --- a/types/graphql/type/definition.d.ts +++ b/types/graphql/type/definition.d.ts @@ -16,6 +16,10 @@ import { FieldNode, FragmentDefinitionNode, ValueNode, + ScalarTypeExtensionNode, + UnionTypeExtensionNode, + EnumTypeExtensionNode, + InputObjectTypeExtensionNode, } from "../language/ast"; import { GraphQLSchema } from "./schema"; @@ -256,7 +260,8 @@ export type Thunk = (() => T) | T; export class GraphQLScalarType { name: string; description: Maybe; - astNode?: Maybe; + astNode: Maybe; + extensionASTNodes: Maybe>; constructor(config: GraphQLScalarTypeConfig); // Serializes an internal value to include in a response. @@ -277,6 +282,7 @@ export interface GraphQLScalarTypeConfig { name: string; description?: Maybe; astNode?: Maybe; + extensionASTNodes?: Maybe>; serialize(value: any): Maybe; parseValue?(value: any): Maybe; parseLiteral?(valueNode: ValueNode, variables: Maybe<{ [key: string]: any }>): Maybe; @@ -502,7 +508,8 @@ export interface GraphQLInterfaceTypeConfig { export class GraphQLUnionType { name: string; description: Maybe; - astNode?: Maybe; + astNode: Maybe; + extensionASTNodes: Maybe>; resolveType: Maybe>; constructor(config: GraphQLUnionTypeConfig); @@ -525,6 +532,7 @@ export interface GraphQLUnionTypeConfig { resolveType?: Maybe>; description?: Maybe; astNode?: Maybe; + extensionASTNodes?: Maybe>; } /** @@ -552,6 +560,7 @@ export class GraphQLEnumType { name: string; description: Maybe; astNode: Maybe; + extensionASTNodes: Maybe>; constructor(config: GraphQLEnumTypeConfig); getValues(): GraphQLEnumValue[]; @@ -569,6 +578,7 @@ export interface GraphQLEnumTypeConfig { values: GraphQLEnumValueConfigMap; description?: Maybe; astNode?: Maybe; + extensionASTNodes?: Maybe>; } export type GraphQLEnumValueConfigMap = { [key: string]: GraphQLEnumValueConfig }; @@ -613,6 +623,7 @@ export class GraphQLInputObjectType { name: string; description: Maybe; astNode: Maybe; + extensionASTNodes: Maybe>; constructor(config: GraphQLInputObjectTypeConfig); getFields(): GraphQLInputFieldMap; toString(): string; @@ -625,6 +636,7 @@ export interface GraphQLInputObjectTypeConfig { fields: Thunk; description?: Maybe; astNode?: Maybe; + extensionASTNodes?: Maybe>; } export interface GraphQLInputFieldConfig { diff --git a/types/graphql/type/schema.d.ts b/types/graphql/type/schema.d.ts index b5ddc9d8d4..19a9acbe8d 100644 --- a/types/graphql/type/schema.d.ts +++ b/types/graphql/type/schema.d.ts @@ -1,7 +1,7 @@ import Maybe from "../tsutils/Maybe"; import { GraphQLObjectType } from "./definition"; import { GraphQLType, GraphQLNamedType, GraphQLAbstractType } from "./definition"; -import { SchemaDefinitionNode } from "../language/ast"; +import { SchemaDefinitionNode, SchemaExtensionNode } from "../language/ast"; import { GraphQLDirective } from "./directives"; /** @@ -37,6 +37,7 @@ export function isSchema(schema: any): schema is GraphQLSchema; */ export class GraphQLSchema { astNode: Maybe; + extensionASTNodes: Maybe>; constructor(config: GraphQLSchemaConfig); @@ -83,4 +84,5 @@ export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions { types?: Maybe; directives?: Maybe; astNode?: Maybe; + extensionASTNodes?: Maybe>; } diff --git a/types/graphql/utilities/buildASTSchema.d.ts b/types/graphql/utilities/buildASTSchema.d.ts index e2406c7ee1..89535d722f 100644 --- a/types/graphql/utilities/buildASTSchema.d.ts +++ b/types/graphql/utilities/buildASTSchema.d.ts @@ -7,8 +7,10 @@ import { NamedTypeNode, DirectiveDefinitionNode, FieldDefinitionNode, + InputValueDefinitionNode, + EnumValueDefinitionNode, } from "../language/ast"; -import { GraphQLNamedType, GraphQLFieldConfig } from "../type/definition"; +import { GraphQLNamedType, GraphQLFieldConfig, GraphQLInputField, GraphQLEnumValueConfig } from "../type/definition"; import { GraphQLDirective } from "../type/directives"; import { Source } from "../language/source"; import { GraphQLSchema, GraphQLSchemaValidationOptions } from "../type/schema"; @@ -57,6 +59,10 @@ export class ASTDefinitionBuilder { buildDirective(directiveNode: DirectiveDefinitionNode): GraphQLDirective; buildField(field: FieldDefinitionNode): GraphQLFieldConfig; + + buildInputField(value: InputValueDefinitionNode): GraphQLInputField; + + buildEnumValue(value: EnumValueDefinitionNode): GraphQLEnumValueConfig; } /** diff --git a/types/graphql/utilities/getOperationRootType.d.ts b/types/graphql/utilities/getOperationRootType.d.ts new file mode 100644 index 0000000000..e1f88e7e13 --- /dev/null +++ b/types/graphql/utilities/getOperationRootType.d.ts @@ -0,0 +1,11 @@ +import { GraphQLSchema } from "../type/schema"; +import { OperationDefinitionNode, OperationTypeDefinitionNode } from "../language/ast"; +import { GraphQLObjectType } from "../type/definition"; + +/** + * Extracts the root type of the operation from the schema. + */ +export function getOperationRootType( + schema: GraphQLSchema, + operation: OperationDefinitionNode | OperationTypeDefinitionNode +): GraphQLObjectType; diff --git a/types/graphql/utilities/index.d.ts b/types/graphql/utilities/index.d.ts index f571c3ab76..e2794bdc98 100644 --- a/types/graphql/utilities/index.d.ts +++ b/types/graphql/utilities/index.d.ts @@ -1,7 +1,7 @@ // The GraphQL query recommended for a full schema introspection. export { getIntrospectionQuery, - // Deprecated, use getIntrospectionQuery() + // @deprecated, use getIntrospectionQuery() - will be removed in v15 introspectionQuery, } from "./introspectionQuery"; @@ -33,6 +33,9 @@ export { // Gets the target Operation from a Document export { getOperationAST } from "./getOperationAST"; +// Gets the Type for the target Operation AST. +export { getOperationRootType } from "./getOperationRootType"; + // Convert a GraphQLSchema to an IntrospectionQuery export { introspectionFromSchema } from "./introspectionFromSchema"; @@ -70,10 +73,10 @@ export { TypeInfo } from "./TypeInfo"; // Coerces a JavaScript value to a GraphQL type, or produces errors. export { coerceValue } from "./coerceValue"; -// @deprecated use coerceValue +// @deprecated use coerceValue - will be removed in v15 export { isValidJSValue } from "./isValidJSValue"; -// Determine if AST values adhere to a GraphQL type. +// @deprecated use validation - will be removed in v15 export { isValidLiteralValue } from "./isValidLiteralValue"; // Concatenates multiple AST together. diff --git a/types/graphql/utilities/introspectionQuery.d.ts b/types/graphql/utilities/introspectionQuery.d.ts index f2172595f8..a256f96cd4 100644 --- a/types/graphql/utilities/introspectionQuery.d.ts +++ b/types/graphql/utilities/introspectionQuery.d.ts @@ -9,6 +9,11 @@ export interface IntrospectionOptions { export function getIntrospectionQuery(options?: IntrospectionOptions): string; +/** + * Deprecated, call getIntrospectionQuery directly. + * + * This function will be removed in v15 + */ export const introspectionQuery: string; export interface IntrospectionQuery { diff --git a/types/graphql/utilities/isValidJSValue.d.ts b/types/graphql/utilities/isValidJSValue.d.ts index d45d104ffd..e64a64d768 100644 --- a/types/graphql/utilities/isValidJSValue.d.ts +++ b/types/graphql/utilities/isValidJSValue.d.ts @@ -2,5 +2,7 @@ import { GraphQLInputType } from "../type/definition"; /** * Deprecated. Use coerceValue() directly for richer information. + * + * This function will be removed in v15 */ export function isValidJSValue(value: any, type: GraphQLInputType): string[]; diff --git a/types/graphql/utilities/isValidLiteralValue.d.ts b/types/graphql/utilities/isValidLiteralValue.d.ts index 6a9275bce9..34ee223ba2 100644 --- a/types/graphql/utilities/isValidLiteralValue.d.ts +++ b/types/graphql/utilities/isValidLiteralValue.d.ts @@ -6,5 +6,7 @@ import { GraphQLInputType } from "../type/definition"; * Utility which determines if a value literal node is valid for an input type. * * Deprecated. Rely on validation for documents containing literal values. + * + * This function will be removed in v15 */ export function isValidLiteralValue(type: GraphQLInputType, valueNode: ValueNode): ReadonlyArray; diff --git a/types/graphql/validation/index.d.ts b/types/graphql/validation/index.d.ts index 911c592432..c321f258dd 100644 --- a/types/graphql/validation/index.d.ts +++ b/types/graphql/validation/index.d.ts @@ -45,7 +45,7 @@ export { OverlappingFieldsCanBeMerged as OverlappingFieldsCanBeMergedRule } from export { PossibleFragmentSpreads as PossibleFragmentSpreadsRule } from "./rules/PossibleFragmentSpreads"; // Spec Section: "Argument Optionality" -export { ProvidedNonNullArguments as ProvidedNonNullArgumentsRule } from "./rules/ProvidedNonNullArguments"; +export { ProvidedRequiredArguments as ProvidedRequiredArgumentsRule } from "./rules/ProvidedRequiredArguments"; // Spec Section: "Leaf Field Selections" export { ScalarLeafs as ScalarLeafsRule } from "./rules/ScalarLeafs"; @@ -77,8 +77,5 @@ export { ValuesOfCorrectType as ValuesOfCorrectTypeRule } from "./rules/ValuesOf // Spec Section: "Variables are Input Types" export { VariablesAreInputTypes as VariablesAreInputTypesRule } from "./rules/VariablesAreInputTypes"; -// Spec Section: "Variables Default Value Is Allowed" -export { VariablesDefaultValueAllowed as VariablesDefaultValueAllowedRule } from "./rules/VariablesDefaultValueAllowed"; - // Spec Section: "All Variable Usages Are Allowed" export { VariablesInAllowedPosition as VariablesInAllowedPositionRule } from "./rules/VariablesInAllowedPosition"; diff --git a/types/graphql/validation/rules/FragmentsOnCompositeTypes.d.ts b/types/graphql/validation/rules/FragmentsOnCompositeTypes.d.ts index 7c760e331f..9c6595b51a 100644 --- a/types/graphql/validation/rules/FragmentsOnCompositeTypes.d.ts +++ b/types/graphql/validation/rules/FragmentsOnCompositeTypes.d.ts @@ -1,10 +1,9 @@ import ValidationContext from "../ValidationContext"; import { ASTVisitor } from "../../language/visitor"; -import { GraphQLType } from "../../type/definition"; -export function inlineFragmentOnNonCompositeErrorMessage(type: GraphQLType): string; +export function inlineFragmentOnNonCompositeErrorMessage(type: string): string; -export function fragmentOnNonCompositeErrorMessage(fragName: string, type: GraphQLType): string; +export function fragmentOnNonCompositeErrorMessage(fragName: string, type: string): string; /** * Fragments on composite type diff --git a/types/graphql/validation/rules/PossibleFragmentSpreads.d.ts b/types/graphql/validation/rules/PossibleFragmentSpreads.d.ts index f318cb189e..53216d0248 100644 --- a/types/graphql/validation/rules/PossibleFragmentSpreads.d.ts +++ b/types/graphql/validation/rules/PossibleFragmentSpreads.d.ts @@ -1,10 +1,9 @@ import ValidationContext from "../ValidationContext"; import { ASTVisitor } from "../../language/visitor"; -import { GraphQLType } from "../../type/definition"; -export function typeIncompatibleSpreadMessage(fragName: string, parentType: GraphQLType, fragType: GraphQLType): string; +export function typeIncompatibleSpreadMessage(fragName: string, parentType: string, fragType: string): string; -export function typeIncompatibleAnonSpreadMessage(parentType: GraphQLType, fragType: GraphQLType): string; +export function typeIncompatibleAnonSpreadMessage(parentType: string, fragType: string): string; /** * Possible fragment spread diff --git a/types/graphql/validation/rules/ProvidedNonNullArguments.d.ts b/types/graphql/validation/rules/ProvidedNonNullArguments.d.ts deleted file mode 100644 index e442b47f83..0000000000 --- a/types/graphql/validation/rules/ProvidedNonNullArguments.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import ValidationContext from "../ValidationContext"; -import { ASTVisitor } from "../../language/visitor"; -import { GraphQLType } from "../../type/definition"; - -export function missingFieldArgMessage(fieldName: string, argName: string, type: GraphQLType): string; - -export function missingDirectiveArgMessage(directiveName: string, argName: string, type: GraphQLType): string; - -/** - * Provided required arguments - * - * A field or directive is only valid if all required (non-null) field arguments - * have been provided. - */ -export function ProvidedNonNullArguments(context: ValidationContext): ASTVisitor; diff --git a/types/graphql/validation/rules/ProvidedRequiredArguments.d.ts b/types/graphql/validation/rules/ProvidedRequiredArguments.d.ts new file mode 100644 index 0000000000..e578815b25 --- /dev/null +++ b/types/graphql/validation/rules/ProvidedRequiredArguments.d.ts @@ -0,0 +1,14 @@ +import ValidationContext from "../ValidationContext"; +import { ASTVisitor } from "../../language/visitor"; + +export function missingFieldArgMessage(fieldName: string, argName: string, type: string): string; + +export function missingDirectiveArgMessage(directiveName: string, argName: string, type: string): string; + +/** + * Provided required arguments + * + * A field or directive is only valid if all required (non-null without a + * default value) field arguments have been provided. + */ +export function ProvidedRequiredArguments(context: ValidationContext): ASTVisitor; diff --git a/types/graphql/validation/rules/ScalarLeafs.d.ts b/types/graphql/validation/rules/ScalarLeafs.d.ts index 5bbf85043a..558cd91cee 100644 --- a/types/graphql/validation/rules/ScalarLeafs.d.ts +++ b/types/graphql/validation/rules/ScalarLeafs.d.ts @@ -1,10 +1,9 @@ import ValidationContext from "../ValidationContext"; import { ASTVisitor } from "../../language/visitor"; -import { GraphQLType } from "../../type/definition"; -export function noSubselectionAllowedMessage(fieldName: string, type: GraphQLType): string; +export function noSubselectionAllowedMessage(fieldName: string, type: string): string; -export function requiredSubselectionMessage(fieldName: string, type: GraphQLType): string; +export function requiredSubselectionMessage(fieldName: string, type: string): string; /** * Scalar leafs diff --git a/types/graphql/validation/rules/VariablesDefaultValueAllowed.d.ts b/types/graphql/validation/rules/VariablesDefaultValueAllowed.d.ts deleted file mode 100644 index 1961eb645e..0000000000 --- a/types/graphql/validation/rules/VariablesDefaultValueAllowed.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import ValidationContext from "../ValidationContext"; -import { ASTVisitor } from "../../language/visitor"; -import { GraphQLType } from "../../type/definition"; - -export function defaultForRequiredVarMessage(varName: string, type: GraphQLType, guessType: GraphQLType): string; - -/** - * Variable's default value is allowed - * - * A GraphQL document is only valid if all variable default values are allowed - * due to a variable not being required. - */ -export function VariablesDefaultValueAllowed(context: ValidationContext): ASTVisitor; diff --git a/types/graphql/validation/rules/VariablesInAllowedPosition.d.ts b/types/graphql/validation/rules/VariablesInAllowedPosition.d.ts index f21ed5c7fb..891d344714 100644 --- a/types/graphql/validation/rules/VariablesInAllowedPosition.d.ts +++ b/types/graphql/validation/rules/VariablesInAllowedPosition.d.ts @@ -1,8 +1,7 @@ import ValidationContext from "../ValidationContext"; import { ASTVisitor } from "../../language/visitor"; -import { GraphQLType } from "../../type/definition"; -export function badVarPosMessage(varName: string, varType: GraphQLType, expectedType: GraphQLType): string; +export function badVarPosMessage(varName: string, varType: string, expectedType: string): string; /** * Variables passed to field arguments conform to type diff --git a/types/graphql/validation/specifiedRules.d.ts b/types/graphql/validation/specifiedRules.d.ts index 8e9815377f..85522503df 100644 --- a/types/graphql/validation/specifiedRules.d.ts +++ b/types/graphql/validation/specifiedRules.d.ts @@ -65,10 +65,7 @@ import { UniqueArgumentNames } from "./rules/UniqueArgumentNames"; import { ValuesOfCorrectType } from "./rules/ValuesOfCorrectType"; // Spec Section: "Argument Optionality" -import { ProvidedNonNullArguments } from "./rules/ProvidedNonNullArguments"; - -// Spec Section: "Variables Default Value Is Allowed" -import { VariablesDefaultValueAllowed } from "./rules/VariablesDefaultValueAllowed"; +import { ProvidedRequiredArguments } from "./rules/ProvidedRequiredArguments"; // Spec Section: "All Variable Usages Are Allowed" import { VariablesInAllowedPosition } from "./rules/VariablesInAllowedPosition";