diff --git a/package.json b/package.json index 0cc32eb9eb..5c2ce7c6c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "graphql", - "version": "14.5.1", + "version": "14.5.2", "description": "A Query Language and Runtime which can target any service.", "license": "MIT", "private": true, diff --git a/src/type/definition.js b/src/type/definition.js index b52f87c72f..3fe9920246 100644 --- a/src/type/definition.js +++ b/src/type/definition.js @@ -791,6 +791,7 @@ function defineFieldMap( })); return { + ...fieldConfig, name: fieldName, description: fieldConfig.description, type: fieldConfig.type, @@ -1423,6 +1424,7 @@ function defineInputFieldMap( ); return { + ...fieldConfig, name: fieldName, description: fieldConfig.description, type: fieldConfig.type, diff --git a/src/version.js b/src/version.js index 1c2451a647..c486590536 100644 --- a/src/version.js +++ b/src/version.js @@ -8,7 +8,7 @@ /** * A string containing the version of the GraphQL.js library */ -export const version = '14.5.1'; +export const version = '14.5.2'; /** * An object containing the components of the GraphQL.js version string @@ -16,6 +16,6 @@ export const version = '14.5.1'; export const versionInfo = Object.freeze({ major: 14, minor: 5, - patch: 1, + patch: 2, preReleaseTag: null, }); diff --git a/tstypes/graphql.d.ts b/tstypes/graphql.d.ts index a1c43c0d5f..90b29c9c4d 100644 --- a/tstypes/graphql.d.ts +++ b/tstypes/graphql.d.ts @@ -1,7 +1,7 @@ import Maybe from './tsutils/Maybe'; import { Source } from './language/source'; -import { GraphQLFieldResolver } from './type/definition'; import { GraphQLSchema } from './type/schema'; +import { GraphQLFieldResolver, GraphQLTypeResolver } from './type/definition'; import { ExecutionResult, ExecutionResultDataDefault, @@ -44,12 +44,13 @@ import { */ export interface GraphQLArgs { schema: GraphQLSchema; - source: Source | string; + source: string | Source; rootValue?: any; contextValue?: any; variableValues?: Maybe<{ [key: string]: any }>; operationName?: Maybe; fieldResolver?: Maybe>; + typeResolver?: Maybe>; } export function graphql( @@ -63,6 +64,7 @@ export function graphql( variableValues?: Maybe<{ [key: string]: any }>, operationName?: Maybe, fieldResolver?: Maybe>, + typeResolver?: Maybe>, ): Promise>; /** @@ -82,4 +84,5 @@ export function graphqlSync( variableValues?: Maybe<{ [key: string]: any }>, operationName?: Maybe, fieldResolver?: Maybe>, + typeResolver?: Maybe>, ): ExecutionResult; diff --git a/tstypes/index.d.ts b/tstypes/index.d.ts index f9a5acbdd7..942cc2e918 100644 --- a/tstypes/index.d.ts +++ b/tstypes/index.d.ts @@ -1,12 +1,40 @@ // TypeScript Version: 2.6 +/** + * GraphQL.js provides a reference implementation for the GraphQL specification + * but is also a useful utility for operating on GraphQL files and building + * sophisticated tools. + * + * This primary module exports a general purpose function for fulfilling all + * steps of the GraphQL specification in a single operation, but also includes + * utilities for every part of the GraphQL specification: + * + * - Parsing the GraphQL language. + * - Building a GraphQL type schema. + * - Validating a GraphQL request against a type schema. + * - Executing a GraphQL request against a type schema. + * + * This also includes utility functions for operating on GraphQL types and + * GraphQL documents to facilitate building tools. + * + * You may also import from each sub-directory directly. For example, the + * following two import statements are equivalent: + * + * import { parse } from 'graphql'; + * import { parse } from 'graphql/language'; + */ + +// The GraphQL.js version info. +export { version, versionInfo } from './version'; + // The primary entry point into fulfilling a GraphQL request. -export { graphql, graphqlSync, GraphQLArgs } from './graphql'; +export { GraphQLArgs, graphql, graphqlSync } from './graphql'; // Create and operate on GraphQL type definitions and schema. export { - GraphQLSchema, // Definitions + GraphQLSchema, + GraphQLDirective, GraphQLScalarType, GraphQLObjectType, GraphQLInterfaceType, @@ -15,10 +43,7 @@ export { GraphQLInputObjectType, GraphQLList, GraphQLNonNull, - GraphQLDirective, - // "Enum" of Type Kinds - TypeKind, - // Scalars + // Standard GraphQL Scalars specifiedScalarTypes, GraphQLInt, GraphQLFloat, @@ -30,12 +55,10 @@ export { GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective, + // "Enum" of Type Kinds + TypeKind, // Constant Deprecation Reason DEFAULT_DEPRECATION_REASON, - // Meta-field definitions. - SchemaMetaFieldDef, - TypeMetaFieldDef, - TypeNameMetaFieldDef, // GraphQL Types for introspection. introspectionTypes, __Schema, @@ -46,6 +69,10 @@ export { __InputValue, __EnumValue, __TypeKind, + // Meta-field definitions. + SchemaMetaFieldDef, + TypeMetaFieldDef, + TypeNameMetaFieldDef, // Predicates isSchema, isDirective, @@ -72,6 +99,8 @@ export { isIntrospectionType, isSpecifiedDirective, // Assertions + assertSchema, + assertDirective, assertType, assertScalarType, assertObjectType, @@ -95,7 +124,9 @@ export { // Validate GraphQL schema. validateSchema, assertValidSchema, - // type +} from './type'; + +export { GraphQLType, GraphQLInputType, GraphQLOutputType, @@ -107,6 +138,7 @@ export { GraphQLNamedType, Thunk, GraphQLSchemaConfig, + GraphQLDirectiveConfig, GraphQLArgument, GraphQLArgumentConfig, GraphQLEnumTypeConfig, @@ -132,7 +164,6 @@ export { GraphQLScalarTypeConfig, GraphQLTypeResolver, GraphQLUnionTypeConfig, - GraphQLDirectiveConfig, GraphQLScalarSerializer, GraphQLScalarValueParser, GraphQLScalarLiteralParser, @@ -142,6 +173,12 @@ export { export { Source, getLocation, + // Print source location + printLocation, + printSourceLocation, + // Lex + createLexer, + TokenKind, // Parse parse, parseValue, @@ -153,10 +190,9 @@ export { visitInParallel, visitWithTypeInfo, getVisitFn, + BREAK, Kind, - TokenKind, DirectiveLocation, - BREAK, // Predicates isDefinitionNode, isExecutableDefinitionNode, @@ -167,20 +203,26 @@ export { isTypeDefinitionNode, isTypeSystemExtensionNode, isTypeExtensionNode, - // type +} from './language'; + +export { Lexer, ParseOptions, SourceLocation, + Location, + Token, + TokenKindEnum, + KindEnum, + DirectiveLocationEnum, // Visitor utilities ASTVisitor, Visitor, VisitFn, VisitorKeyMap, // AST nodes - Location, - Token, ASTNode, ASTKindToNode, + // Each kind of AST node NameNode, DocumentNode, DefinitionNode, @@ -234,25 +276,26 @@ export { UnionTypeExtensionNode, EnumTypeExtensionNode, InputObjectTypeExtensionNode, - KindEnum, - TokenKindEnum, - DirectiveLocationEnum, } from './language'; // Execute GraphQL queries. export { execute, defaultFieldResolver, + defaultTypeResolver, responsePathAsArray, getDirectiveValues, - // type ExecutionArgs, ExecutionResult, } from './execution'; -export { subscribe, createSourceEventStream } from './subscription'; +export { + subscribe, + createSourceEventStream, + SubscriptionArgs, +} from './subscription'; -// Validate GraphQL queries. +// Validate GraphQL documents. export { validate, ValidationContext, @@ -284,13 +327,16 @@ export { ValuesOfCorrectTypeRule, VariablesAreInputTypesRule, VariablesInAllowedPositionRule, + ValidationRule, } from './validation'; -// Create and format GraphQL errors. +// Create, format, and print GraphQL errors. export { GraphQLError, - formatError, + syntaxError, + locatedError, printError, + formatError, GraphQLFormattedError, } from './error'; @@ -299,13 +345,13 @@ export { // Produce the GraphQL query recommended for a full schema introspection. // Accepts optional IntrospectionOptions. getIntrospectionQuery, - // @deprecated: use getIntrospectionQuery - will be removed in v15 + // @deprecated: use getIntrospectionQuery - will be removed in v15. introspectionQuery, - // Gets the target Operation from a Document + // Gets the target Operation from a Document. getOperationAST, // Gets the Type for the target Operation AST. getOperationRootType, - // Convert a GraphQLSchema to an IntrospectionQuery + // Convert a GraphQLSchema to an IntrospectionQuery. introspectionFromSchema, // Build a GraphQLSchema from an introspection result. buildClientSchema, @@ -314,7 +360,7 @@ export { // Build a GraphQLSchema from a GraphQL schema language document. buildSchema, // @deprecated: Get the description from a schema AST node and supports legacy - // syntax for specifying descriptions - will be removed in v16 + // syntax for specifying descriptions - will be removed in v16. getDescription, // Extends an existing GraphQLSchema from a parsed GraphQL Schema // language AST. @@ -323,11 +369,11 @@ export { lexicographicSortSchema, // Print a GraphQLSchema to GraphQL Schema language. printSchema, + // Print a GraphQLType to GraphQL Schema language. + printType, // Prints the built-in introspection schema in the Schema Language // format. printIntrospectionSchema, - // Print a GraphQLType to GraphQL Schema language. - printType, // Create a GraphQLType from a GraphQL language AST. typeFromAST, // Create a JavaScript value from a GraphQL language AST with a Type. @@ -340,8 +386,10 @@ export { // the GraphQL type system. TypeInfo, // Coerces a JavaScript value to a GraphQL type, or produces errors. + coerceInputValue, + // @deprecated use coerceInputValue - will be removed in v15 coerceValue, - // @deprecated use coerceValue - will be removed in v15 + // @deprecated use coerceInputValue - will be removed in v15 isValidJSValue, // @deprecated use validation - will be removed in v15 isValidLiteralValue, @@ -349,6 +397,9 @@ export { concatAST, // Separates an AST into an AST per Operation. separateOperations, + // Strips characters that are not significant to the validity or execution + // of a GraphQL document. + stripIgnoredCharacters, // Comparators for types isEqualType, isTypeSubTypeOf, @@ -358,36 +409,38 @@ export { // Determine if a string is a valid GraphQL name. isValidNameError, // Compares two GraphQLSchemas and detects breaking changes. - findBreakingChanges, - findDangerousChanges, BreakingChangeType, DangerousChangeType, + findBreakingChanges, + findDangerousChanges, // Report all deprecated usage within a GraphQL document. findDeprecatedUsages, - // type - BuildSchemaOptions, - BreakingChange, - DangerousChange, +} from './utilities'; + +export { IntrospectionOptions, - IntrospectionDirective, + IntrospectionQuery, + IntrospectionSchema, + IntrospectionType, + IntrospectionInputType, + IntrospectionOutputType, + IntrospectionScalarType, + IntrospectionObjectType, + IntrospectionInterfaceType, + IntrospectionUnionType, IntrospectionEnumType, - IntrospectionEnumValue, - IntrospectionField, IntrospectionInputObjectType, - IntrospectionInputType, + IntrospectionTypeRef, IntrospectionInputTypeRef, - IntrospectionInputValue, - IntrospectionInterfaceType, - IntrospectionListTypeRef, + IntrospectionOutputTypeRef, IntrospectionNamedTypeRef, + IntrospectionListTypeRef, IntrospectionNonNullTypeRef, - IntrospectionObjectType, - IntrospectionOutputType, - IntrospectionOutputTypeRef, - IntrospectionQuery, - IntrospectionScalarType, - IntrospectionSchema, - IntrospectionType, - IntrospectionTypeRef, - IntrospectionUnionType, + IntrospectionField, + IntrospectionInputValue, + IntrospectionEnumValue, + IntrospectionDirective, + BuildSchemaOptions, + BreakingChange, + DangerousChange, } from './utilities'; diff --git a/tstypes/language/index.d.ts b/tstypes/language/index.d.ts index e15060e7f2..7cd95901c9 100644 --- a/tstypes/language/index.d.ts +++ b/tstypes/language/index.d.ts @@ -1,5 +1,8 @@ export { Source } from './source'; export { getLocation, SourceLocation } from './location'; + +export { printLocation, printSourceLocation } from './printLocation'; + export { Kind, KindEnum } from './kinds'; export { TokenKind, TokenKindEnum } from './tokenKind'; export { createLexer, Lexer } from './lexer'; diff --git a/tstypes/type/definition.d.ts b/tstypes/type/definition.d.ts index 28b68dd7ac..b468797748 100644 --- a/tstypes/type/definition.d.ts +++ b/tstypes/type/definition.d.ts @@ -1,5 +1,6 @@ import Maybe from '../tsutils/Maybe'; import { PromiseOrValue } from '../jsutils/PromiseOrValue'; +import { Path } from '../jsutils/Path'; import { ScalarTypeDefinitionNode, ObjectTypeDefinitionNode, @@ -75,6 +76,7 @@ export function assertNonNullType(type: any): GraphQLNonNull; /** * These types may be used as input types for arguments and directives. */ +// TS_SPECIFIC: TS does not allow recursive type definitions, hence the `any`s export type GraphQLInputType = | GraphQLScalarType | GraphQLEnumType @@ -94,6 +96,7 @@ export function assertInputType(type: any): GraphQLInputType; /** * These types may be used as output types as the result of fields. */ +// TS_SPECIFIC: TS does not allow recursive type definitions, hence the `any`s export type GraphQLOutputType = | GraphQLScalarType | GraphQLObjectType @@ -285,13 +288,16 @@ export class GraphQLScalarType { serialize: GraphQLScalarSerializer; parseValue: GraphQLScalarValueParser; parseLiteral: GraphQLScalarLiteralParser; + extensions: Maybe>>; astNode: Maybe; extensionASTNodes: Maybe>; constructor(config: GraphQLScalarTypeConfig); toConfig(): GraphQLScalarTypeConfig & { + serialize: GraphQLScalarSerializer; parseValue: GraphQLScalarValueParser; parseLiteral: GraphQLScalarLiteralParser; + extensions: Maybe>>; extensionASTNodes: ReadonlyArray; }; @@ -320,6 +326,7 @@ export interface GraphQLScalarTypeConfig { parseValue?: GraphQLScalarValueParser; // Parses an externally provided literal value to use as an input. parseLiteral?: GraphQLScalarLiteralParser; + extensions?: Maybe>>; astNode?: Maybe; extensionASTNodes?: Maybe>; } @@ -368,9 +375,10 @@ export class GraphQLObjectType< > { name: string; description: Maybe; + isTypeOf: Maybe>; + extensions: Maybe>>; astNode: Maybe; extensionASTNodes: Maybe>; - isTypeOf: Maybe>; constructor(config: GraphQLObjectTypeConfig); getFields(): GraphQLFieldMap; @@ -387,20 +395,27 @@ export class GraphQLObjectType< inspect(): string; } +export function argsToArgsConfig( + args: ReadonlyArray, +): GraphQLFieldConfigArgumentMap; + +// TS_SPECIFIC: TArgs export interface GraphQLObjectTypeConfig< TSource, TContext, TArgs = { [key: string]: any } > { name: string; + description?: Maybe; interfaces?: Thunk>; fields: Thunk>; isTypeOf?: Maybe>; - description?: Maybe; + extensions?: Maybe>>; astNode?: Maybe; extensionASTNodes?: Maybe>; } +// TS_SPECIFIC: TArgs export type GraphQLTypeResolver< TSource, TContext, @@ -435,7 +450,7 @@ export interface GraphQLResolveInfo { readonly fieldNodes: ReadonlyArray; readonly returnType: GraphQLOutputType; readonly parentType: GraphQLObjectType; - readonly path: ResponsePath; + readonly path: Path; readonly schema: GraphQLSchema; readonly fragments: { [key: string]: FragmentDefinitionNode }; readonly rootValue: any; @@ -443,22 +458,18 @@ export interface GraphQLResolveInfo { readonly variableValues: { [variableName: string]: any }; } -export type ResponsePath = { - readonly prev: ResponsePath | undefined; - readonly key: string | number; -}; - export interface GraphQLFieldConfig< TSource, TContext, TArgs = { [argName: string]: any } > { + description?: Maybe; type: GraphQLOutputType; args?: GraphQLFieldConfigArgumentMap; resolve?: GraphQLFieldResolver; subscribe?: GraphQLFieldResolver; deprecationReason?: Maybe; - description?: Maybe; + extensions?: Maybe>>; astNode?: Maybe; } @@ -467,12 +478,14 @@ export type GraphQLFieldConfigArgumentMap = { }; export interface GraphQLArgumentConfig { + description?: Maybe; type: GraphQLInputType; defaultValue?: any; - description?: Maybe; + extensions?: Maybe>>; astNode?: Maybe; } +// TS_SPECIFIC: TArgs export type GraphQLFieldConfigMap< TSource, TContext, @@ -494,19 +507,22 @@ export interface GraphQLField< subscribe?: GraphQLFieldResolver; isDeprecated?: boolean; deprecationReason?: Maybe; + extensions: Maybe>>; astNode?: Maybe; } export interface GraphQLArgument { name: string; + description: Maybe; type: GraphQLInputType; - defaultValue?: any; - description?: Maybe; - astNode?: Maybe; + defaultValue: any; + extensions: Maybe>>; + astNode: Maybe; } export function isRequiredArgument(arg: GraphQLArgument): boolean; +// TS_SPECIFIC: TArgs export type GraphQLFieldMap< TSource, TContext, @@ -536,9 +552,10 @@ export type GraphQLFieldMap< export class GraphQLInterfaceType { name: string; description: Maybe; + resolveType: Maybe>; + extensions: Maybe>>; astNode?: Maybe; extensionASTNodes: Maybe>; - resolveType: Maybe>; constructor(config: GraphQLInterfaceTypeConfig); @@ -546,6 +563,7 @@ export class GraphQLInterfaceType { toConfig(): GraphQLInterfaceTypeConfig & { fields: GraphQLFieldConfigMap; + extensions: Maybe>>; extensionASTNodes: ReadonlyArray; }; @@ -554,12 +572,14 @@ export class GraphQLInterfaceType { inspect(): string; } +// TS_SPECIFIC: TArgs export interface GraphQLInterfaceTypeConfig< TSource, TContext, TArgs = { [key: string]: any } > { name: string; + description?: Maybe; fields: Thunk>; /** * Optionally provide a custom type resolver function. If one is not provided, @@ -567,7 +587,7 @@ export interface GraphQLInterfaceTypeConfig< * Object type. */ resolveType?: Maybe>; - description?: Maybe; + extensions?: Maybe>>; astNode?: Maybe; extensionASTNodes?: Maybe>; } @@ -598,9 +618,10 @@ export interface GraphQLInterfaceTypeConfig< export class GraphQLUnionType { name: string; description: Maybe; + resolveType: Maybe>; + extensions: Maybe>>; astNode: Maybe; extensionASTNodes: Maybe>; - resolveType: Maybe>; constructor(config: GraphQLUnionTypeConfig); @@ -618,6 +639,7 @@ export class GraphQLUnionType { export interface GraphQLUnionTypeConfig { name: string; + description?: Maybe; types: Thunk; /** * Optionally provide a custom type resolver function. If one is not provided, @@ -625,7 +647,7 @@ export interface GraphQLUnionTypeConfig { * Object type. */ resolveType?: Maybe>; - description?: Maybe; + extensions?: Maybe>>; astNode?: Maybe; extensionASTNodes?: Maybe>; } @@ -654,6 +676,7 @@ export interface GraphQLUnionTypeConfig { export class GraphQLEnumType { name: string; description: Maybe; + extensions: Maybe>>; astNode: Maybe; extensionASTNodes: Maybe>; @@ -678,8 +701,9 @@ export class GraphQLEnumType { export interface GraphQLEnumTypeConfig { name: string; - values: GraphQLEnumValueConfigMap; description?: Maybe; + values: GraphQLEnumValueConfigMap; + extensions?: Maybe>>; astNode?: Maybe; extensionASTNodes?: Maybe>; } @@ -689,19 +713,21 @@ export type GraphQLEnumValueConfigMap = { }; export interface GraphQLEnumValueConfig { + description?: Maybe; value?: any; deprecationReason?: Maybe; - description?: Maybe; + extensions?: Maybe>>; astNode?: Maybe; } export interface GraphQLEnumValue { name: string; description: Maybe; + value: any; isDeprecated?: boolean; deprecationReason: Maybe; + extensions: Maybe>>; astNode?: Maybe; - value: any; } /** @@ -727,6 +753,7 @@ export interface GraphQLEnumValue { export class GraphQLInputObjectType { name: string; description: Maybe; + extensions: Maybe>>; astNode: Maybe; extensionASTNodes: Maybe>; constructor(config: GraphQLInputObjectTypeConfig); @@ -734,6 +761,7 @@ export class GraphQLInputObjectType { toConfig(): GraphQLInputObjectTypeConfig & { fields: GraphQLInputFieldConfigMap; + extensions: Maybe>>; extensionASTNodes: ReadonlyArray; }; @@ -744,16 +772,18 @@ export class GraphQLInputObjectType { export interface GraphQLInputObjectTypeConfig { name: string; - fields: Thunk; description?: Maybe; + fields: Thunk; + extensions?: Maybe>>; astNode?: Maybe; extensionASTNodes?: Maybe>; } export interface GraphQLInputFieldConfig { + description?: Maybe; type: GraphQLInputType; defaultValue?: any; - description?: Maybe; + extensions?: Maybe>>; astNode?: Maybe; } @@ -763,9 +793,10 @@ export type GraphQLInputFieldConfigMap = { export interface GraphQLInputField { name: string; + description?: Maybe; type: GraphQLInputType; defaultValue?: any; - description?: Maybe; + extensions: Maybe>>; astNode?: Maybe; } diff --git a/tstypes/type/directives.d.ts b/tstypes/type/directives.d.ts index c085aee35b..9719bf600e 100644 --- a/tstypes/type/directives.d.ts +++ b/tstypes/type/directives.d.ts @@ -7,7 +7,7 @@ import { DirectiveLocationEnum } from '../language/directiveLocation'; * Test if the given value is a GraphQL directive. */ export function isDirective(directive: any): directive is GraphQLDirective; - +export function assertDirective(directive: any): GraphQLDirective; /** * Directives are used by the GraphQL runtime as a way of modifying execution * behavior. Type system creators will usually not create these directly. @@ -18,12 +18,17 @@ export class GraphQLDirective { locations: DirectiveLocationEnum[]; isRepeatable: boolean; args: GraphQLArgument[]; + extensions?: Maybe>>; astNode: Maybe; constructor(config: GraphQLDirectiveConfig); + toString(): string; + toConfig(): GraphQLDirectiveConfig & { args: GraphQLFieldConfigArgumentMap; + extensions?: Maybe>>; + isRepeatable: boolean; }; } @@ -33,6 +38,7 @@ export interface GraphQLDirectiveConfig { locations: DirectiveLocationEnum[]; args?: Maybe; isRepeatable?: Maybe; + extensions?: Maybe>>; astNode?: Maybe; } @@ -61,4 +67,6 @@ export const GraphQLDeprecatedDirective: GraphQLDirective; */ export const specifiedDirectives: ReadonlyArray; -export function isSpecifiedDirective(directive: GraphQLDirective): boolean; +export function isSpecifiedDirective( + directive: any, +): directive is GraphQLDirective; diff --git a/tstypes/type/index.d.ts b/tstypes/type/index.d.ts index 209582cb46..b6780d8171 100644 --- a/tstypes/type/index.d.ts +++ b/tstypes/type/index.d.ts @@ -1,6 +1,10 @@ +export { Path as ResponsePath } from '../jsutils/Path'; + export { // Predicate isSchema, + // Assertion + assertSchema, // GraphQL Schema definition GraphQLSchema, GraphQLSchemaConfig, @@ -90,7 +94,6 @@ export { GraphQLIsTypeOfFn, GraphQLObjectTypeConfig, GraphQLResolveInfo, - ResponsePath, GraphQLScalarTypeConfig, GraphQLTypeResolver, GraphQLUnionTypeConfig, @@ -102,6 +105,8 @@ export { export { // Predicate isDirective, + // Assertion + assertDirective, // Directives Definition GraphQLDirective, // Built-in Directives defined by the Spec diff --git a/tstypes/type/introspection.d.ts b/tstypes/type/introspection.d.ts index 9a4dd874ed..3acfe6e210 100644 --- a/tstypes/type/introspection.d.ts +++ b/tstypes/type/introspection.d.ts @@ -1,14 +1,9 @@ import { - GraphQLScalarType, GraphQLObjectType, - GraphQLInterfaceType, - GraphQLUnionType, + GraphQLField, GraphQLEnumType, - GraphQLInputObjectType, - GraphQLList, - GraphQLNonNull, + GraphQLType, } from './definition'; -import { GraphQLField } from './definition'; export const __Schema: GraphQLObjectType; export const __Directive: GraphQLObjectType; @@ -40,6 +35,6 @@ export const SchemaMetaFieldDef: GraphQLField; export const TypeMetaFieldDef: GraphQLField; export const TypeNameMetaFieldDef: GraphQLField; -export const introspectionTypes: ReadonlyArray; +export const introspectionTypes: ReadonlyArray; export function isIntrospectionType(type: any): boolean; diff --git a/tstypes/type/scalars.d.ts b/tstypes/type/scalars.d.ts index 3cd8ad537c..fe16fd5cad 100644 --- a/tstypes/type/scalars.d.ts +++ b/tstypes/type/scalars.d.ts @@ -8,4 +8,4 @@ export const GraphQLID: GraphQLScalarType; export const specifiedScalarTypes: ReadonlyArray; -export function isSpecifiedScalarType(type: GraphQLScalarType): boolean; +export function isSpecifiedScalarType(type: any): type is GraphQLScalarType; diff --git a/tstypes/type/schema.d.ts b/tstypes/type/schema.d.ts index 749eae4a92..5cbddaed60 100644 --- a/tstypes/type/schema.d.ts +++ b/tstypes/type/schema.d.ts @@ -1,17 +1,18 @@ import Maybe from '../tsutils/Maybe'; -import { GraphQLObjectType } from './definition'; +import { SchemaDefinitionNode, SchemaExtensionNode } from '../language/ast'; +import { GraphQLDirective } from './directives'; import { GraphQLType, GraphQLNamedType, GraphQLAbstractType, + GraphQLObjectType, } from './definition'; -import { SchemaDefinitionNode, SchemaExtensionNode } from '../language/ast'; -import { GraphQLDirective } from './directives'; /** * Test if the given value is a GraphQL schema. */ export function isSchema(schema: any): schema is GraphQLSchema; +export function assertSchema(schema: any): GraphQLSchema; /** * Schema Definition @@ -40,6 +41,7 @@ export function isSchema(schema: any): schema is GraphQLSchema; * */ export class GraphQLSchema { + extensions: Maybe>>; astNode: Maybe; extensionASTNodes: Maybe>; @@ -65,7 +67,10 @@ export class GraphQLSchema { toConfig(): GraphQLSchemaConfig & { types: GraphQLNamedType[]; directives: GraphQLDirective[]; + extensions: Maybe>>; extensionASTNodes: ReadonlyArray; + assumeValid: boolean; + allowedLegacyNames: ReadonlyArray; }; } @@ -97,6 +102,7 @@ export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions { subscription?: Maybe; types?: Maybe; directives?: Maybe; + extensions?: Maybe>>; astNode?: Maybe; extensionASTNodes?: Maybe>; } diff --git a/tstypes/type/validate.d.ts b/tstypes/type/validate.d.ts index f6283f652a..9573befe3a 100644 --- a/tstypes/type/validate.d.ts +++ b/tstypes/type/validate.d.ts @@ -1,5 +1,5 @@ -import { GraphQLSchema } from './schema'; import { GraphQLError } from '../error/GraphQLError'; +import { GraphQLSchema } from './schema'; /** * Implements the "Type Validation" sub-sections of the specification's diff --git a/tstypes/utilities/TypeInfo.d.ts b/tstypes/utilities/TypeInfo.d.ts index 74d740b23d..1f2419b632 100644 --- a/tstypes/utilities/TypeInfo.d.ts +++ b/tstypes/utilities/TypeInfo.d.ts @@ -1,16 +1,16 @@ import Maybe from '../tsutils/Maybe'; +import { ASTNode, FieldNode } from '../language/ast'; import { GraphQLSchema } from '../type/schema'; +import { GraphQLDirective } from '../type/directives'; import { + GraphQLType, + GraphQLInputType, GraphQLOutputType, GraphQLCompositeType, - GraphQLInputType, GraphQLField, GraphQLArgument, GraphQLEnumValue, - GraphQLType, } from '../type/definition'; -import { GraphQLDirective } from '../type/directives'; -import { ASTNode, FieldNode } from '../language/ast'; /** * TypeInfo is a utility class which, given a GraphQL schema, can keep track diff --git a/tstypes/utilities/buildASTSchema.d.ts b/tstypes/utilities/buildASTSchema.d.ts index 9c4c58adb6..ec7e73e964 100644 --- a/tstypes/utilities/buildASTSchema.d.ts +++ b/tstypes/utilities/buildASTSchema.d.ts @@ -9,12 +9,16 @@ import { FieldDefinitionNode, InputValueDefinitionNode, EnumValueDefinitionNode, + TypeNode, } from '../language/ast'; import { GraphQLNamedType, GraphQLFieldConfig, GraphQLInputField, GraphQLEnumValueConfig, + GraphQLType, + GraphQLArgumentConfig, + GraphQLInputFieldConfig, } from '../type/definition'; import { GraphQLDirective } from '../type/directives'; import { Source } from '../language/source'; @@ -66,25 +70,23 @@ type TypeDefinitionsMap = { [key: string]: TypeDefinitionNode }; type TypeResolver = (typeRef: NamedTypeNode) => GraphQLNamedType; export class ASTDefinitionBuilder { - constructor( - typeDefinitionsMap: TypeDefinitionsMap, - options: Maybe, - resolveType: TypeResolver, - ); + constructor(options: Maybe, resolveType: TypeResolver); - buildTypes( - nodes: ReadonlyArray, - ): Array; + getNamedType(node: NamedTypeNode): GraphQLNamedType; - buildType(node: NamedTypeNode | TypeDefinitionNode): GraphQLNamedType; + getWrappedType(node: TypeNode): GraphQLType; - buildDirective(directiveNode: DirectiveDefinitionNode): GraphQLDirective; + buildDirective(directive: DirectiveDefinitionNode): GraphQLDirective; buildField(field: FieldDefinitionNode): GraphQLFieldConfig; - buildInputField(value: InputValueDefinitionNode): GraphQLInputField; + buildArg(value: InputValueDefinitionNode): GraphQLArgumentConfig; + + buildInputField(value: InputValueDefinitionNode): GraphQLInputFieldConfig; buildEnumValue(value: EnumValueDefinitionNode): GraphQLEnumValueConfig; + + buildType(node: NamedTypeNode | TypeDefinitionNode): GraphQLNamedType; } /** diff --git a/tstypes/utilities/coerceInputValue.d.ts b/tstypes/utilities/coerceInputValue.d.ts new file mode 100644 index 0000000000..cb8f1a581b --- /dev/null +++ b/tstypes/utilities/coerceInputValue.d.ts @@ -0,0 +1,17 @@ +import { GraphQLInputType } from '../type/definition'; +import { GraphQLError } from 'tstypes/error'; + +type OnErrorCB = ( + path: ReadonlyArray, + invalidValue: any, + error: GraphQLError, +) => void; + +/** + * Coerces a JavaScript value given a GraphQL Input Type. + */ +export function coerceInputValue( + inputValue: any, + type: GraphQLInputType, + onError?: OnErrorCB, +): any; diff --git a/tstypes/utilities/coerceValue.d.ts b/tstypes/utilities/coerceValue.d.ts index 96fafdca6a..f79389eac5 100644 --- a/tstypes/utilities/coerceValue.d.ts +++ b/tstypes/utilities/coerceValue.d.ts @@ -1,3 +1,4 @@ +import { Path } from '../jsutils/Path'; import { GraphQLError } from '../error/GraphQLError'; import { ASTNode } from '../language/ast'; import { GraphQLInputType } from '../type/definition'; @@ -7,11 +8,6 @@ interface CoercedValue { readonly value: any; } -interface Path { - readonly prev: Path | undefined; - readonly key: string | number; -} - /** * Coerces a JavaScript value given a GraphQL Type. * @@ -20,7 +16,7 @@ interface Path { * */ export function coerceValue( - value: any, + inputValue: any, type: GraphQLInputType, blameNode?: ASTNode, path?: Path, diff --git a/tstypes/utilities/extendSchema.d.ts b/tstypes/utilities/extendSchema.d.ts index 2f0007ba89..9df76c2ae4 100644 --- a/tstypes/utilities/extendSchema.d.ts +++ b/tstypes/utilities/extendSchema.d.ts @@ -1,6 +1,5 @@ import { DocumentNode } from '../language/ast'; -import { GraphQLSchema } from '../type/schema'; -import { GraphQLSchemaValidationOptions } from '../type/schema'; +import { GraphQLSchemaValidationOptions, GraphQLSchema } from '../type/schema'; interface Options extends GraphQLSchemaValidationOptions { /** diff --git a/tstypes/utilities/findBreakingChanges.d.ts b/tstypes/utilities/findBreakingChanges.d.ts index 75daa4f946..87fa0c028e 100644 --- a/tstypes/utilities/findBreakingChanges.d.ts +++ b/tstypes/utilities/findBreakingChanges.d.ts @@ -1,13 +1,3 @@ -import { - getNamedType, - GraphQLScalarType, - GraphQLEnumType, - GraphQLInputObjectType, - GraphQLInterfaceType, - GraphQLObjectType, - GraphQLUnionType, - GraphQLNamedType, -} from '../type/definition'; import { GraphQLDirective } from '../type/directives'; import { GraphQLSchema } from '../type/schema'; import { DirectiveLocationEnum } from '../language/directiveLocation'; @@ -16,33 +6,33 @@ export const BreakingChangeType: _BreakingChangeType; // @internal type _BreakingChangeType = { - FIELD_CHANGED_KIND: 'FIELD_CHANGED_KIND'; - FIELD_REMOVED: 'FIELD_REMOVED'; - TYPE_CHANGED_KIND: 'TYPE_CHANGED_KIND'; TYPE_REMOVED: 'TYPE_REMOVED'; + TYPE_CHANGED_KIND: 'TYPE_CHANGED_KIND'; TYPE_REMOVED_FROM_UNION: 'TYPE_REMOVED_FROM_UNION'; VALUE_REMOVED_FROM_ENUM: 'VALUE_REMOVED_FROM_ENUM'; - ARG_REMOVED: 'ARG_REMOVED'; - ARG_CHANGED_KIND: 'ARG_CHANGED_KIND'; - REQUIRED_ARG_ADDED: 'REQUIRED_ARG_ADDED'; REQUIRED_INPUT_FIELD_ADDED: 'REQUIRED_INPUT_FIELD_ADDED'; INTERFACE_REMOVED_FROM_OBJECT: 'INTERFACE_REMOVED_FROM_OBJECT'; + FIELD_REMOVED: 'FIELD_REMOVED'; + FIELD_CHANGED_KIND: 'FIELD_CHANGED_KIND'; + REQUIRED_ARG_ADDED: 'REQUIRED_ARG_ADDED'; + ARG_REMOVED: 'ARG_REMOVED'; + ARG_CHANGED_KIND: 'ARG_CHANGED_KIND'; DIRECTIVE_REMOVED: 'DIRECTIVE_REMOVED'; DIRECTIVE_ARG_REMOVED: 'DIRECTIVE_ARG_REMOVED'; - DIRECTIVE_LOCATION_REMOVED: 'DIRECTIVE_LOCATION_REMOVED'; REQUIRED_DIRECTIVE_ARG_ADDED: 'REQUIRED_DIRECTIVE_ARG_ADDED'; + DIRECTIVE_LOCATION_REMOVED: 'DIRECTIVE_LOCATION_REMOVED'; }; export const DangerousChangeType: _DangerousChangeType; // @internal type _DangerousChangeType = { - ARG_DEFAULT_VALUE_CHANGE: 'ARG_DEFAULT_VALUE_CHANGE'; VALUE_ADDED_TO_ENUM: 'VALUE_ADDED_TO_ENUM'; - INTERFACE_ADDED_TO_OBJECT: 'INTERFACE_ADDED_TO_OBJECT'; TYPE_ADDED_TO_UNION: 'TYPE_ADDED_TO_UNION'; OPTIONAL_INPUT_FIELD_ADDED: 'OPTIONAL_INPUT_FIELD_ADDED'; OPTIONAL_ARG_ADDED: 'OPTIONAL_ARG_ADDED'; + INTERFACE_ADDED_TO_OBJECT: 'INTERFACE_ADDED_TO_OBJECT'; + ARG_DEFAULT_VALUE_CHANGE: 'ARG_DEFAULT_VALUE_CHANGE'; }; export interface BreakingChange { @@ -72,119 +62,3 @@ export function findDangerousChanges( oldSchema: GraphQLSchema, newSchema: GraphQLSchema, ): Array; - -/** - * Given two schemas, returns an Array containing descriptions of any breaking - * changes in the newSchema related to removing an entire type. - */ -export function findRemovedTypes( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array; - -/** - * Given two schemas, returns an Array containing descriptions of any breaking - * changes in the newSchema related to changing the type of a type. - */ -export function findTypesThatChangedKind( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array; - -/** - * Given two schemas, returns an Array containing descriptions of any - * breaking or dangerous changes in the newSchema related to arguments - * (such as removal or change of type of an argument, or a change in an - * argument's default value). - */ -export function findArgChanges( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): { - breakingChanges: Array; - dangerousChanges: Array; -}; - -export function findFieldsThatChangedTypeOnObjectOrInterfaceTypes( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array; - -export function findFieldsThatChangedTypeOnInputObjectTypes( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): { - breakingChanges: Array; - dangerousChanges: Array; -}; - -/** - * Given two schemas, returns an Array containing descriptions of any breaking - * changes in the newSchema related to removing types from a union type. - */ -export function findTypesRemovedFromUnions( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array; - -/** - * Given two schemas, returns an Array containing descriptions of any dangerous - * changes in the newSchema related to adding types to a union type. - */ -export function findTypesAddedToUnions( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array; - -/** - * Given two schemas, returns an Array containing descriptions of any breaking - * changes in the newSchema related to removing values from an enum type. - */ -export function findValuesRemovedFromEnums( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array; - -/** - * Given two schemas, returns an Array containing descriptions of any dangerous - * changes in the newSchema related to adding values to an enum type. - */ -export function findValuesAddedToEnums( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array; - -export function findInterfacesRemovedFromObjectTypes( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array; - -export function findInterfacesAddedToObjectTypes( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array; - -export function findRemovedDirectives( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array; - -export function findRemovedDirectiveArgs( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array; - -export function findAddedNonNullDirectiveArgs( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array; - -export function findRemovedLocationsForDirective( - oldDirective: GraphQLDirective, - newDirective: GraphQLDirective, -): Array; - -export function findRemovedDirectiveLocations( - oldSchema: GraphQLSchema, - newSchema: GraphQLSchema, -): Array; diff --git a/tstypes/utilities/findDeprecatedUsages.d.ts b/tstypes/utilities/findDeprecatedUsages.d.ts index 8cd844e15f..0a55f1b82d 100644 --- a/tstypes/utilities/findDeprecatedUsages.d.ts +++ b/tstypes/utilities/findDeprecatedUsages.d.ts @@ -1,6 +1,6 @@ -import { GraphQLSchema } from '../type/schema'; -import { DocumentNode } from '../language/ast'; import { GraphQLError } from '../error/GraphQLError'; +import { DocumentNode } from '../language/ast'; +import { GraphQLSchema } from '../type/schema'; /** * A validation rule which reports deprecated usages. diff --git a/tstypes/utilities/getOperationRootType.d.ts b/tstypes/utilities/getOperationRootType.d.ts index f82eeecbc1..5adc59c7af 100644 --- a/tstypes/utilities/getOperationRootType.d.ts +++ b/tstypes/utilities/getOperationRootType.d.ts @@ -1,8 +1,8 @@ -import { GraphQLSchema } from '../type/schema'; import { OperationDefinitionNode, OperationTypeDefinitionNode, } from '../language/ast'; +import { GraphQLSchema } from '../type/schema'; import { GraphQLObjectType } from '../type/definition'; /** diff --git a/tstypes/utilities/index.d.ts b/tstypes/utilities/index.d.ts index a459298c5b..f3d82f01ec 100644 --- a/tstypes/utilities/index.d.ts +++ b/tstypes/utilities/index.d.ts @@ -81,6 +81,9 @@ export { astFromValue } from './astFromValue'; // the GraphQL type system. export { TypeInfo } from './TypeInfo'; +// Coerces a JavaScript value to a GraphQL type, or produces errors. +export { coerceInputValue } from './coerceInputValue'; + // Coerces a JavaScript value to a GraphQL type, or produces errors. export { coerceValue } from './coerceValue'; @@ -96,6 +99,10 @@ export { concatAST } from './concatAST'; // Separates an AST into an AST per Operation. export { separateOperations } from './separateOperations'; +// Strips characters that are not significant to the validity or execution +// of a GraphQL document. +export { stripIgnoredCharacters } from './stripIgnoredCharacters'; + // Comparators for types export { isEqualType, diff --git a/tstypes/utilities/separateOperations.d.ts b/tstypes/utilities/separateOperations.d.ts index d3dcb6e957..28654fdb1b 100644 --- a/tstypes/utilities/separateOperations.d.ts +++ b/tstypes/utilities/separateOperations.d.ts @@ -1,4 +1,4 @@ -import { DocumentNode, OperationDefinitionNode } from '../language/ast'; +import { DocumentNode } from '../language/ast'; /** * separateOperations accepts a single AST document which may contain many diff --git a/tstypes/utilities/stripIgnoredCharacters.d.ts b/tstypes/utilities/stripIgnoredCharacters.d.ts new file mode 100644 index 0000000000..a131af02f5 --- /dev/null +++ b/tstypes/utilities/stripIgnoredCharacters.d.ts @@ -0,0 +1,55 @@ +import { Source } from '../language/source'; + +/** + * Strips characters that are not significant to the validity or execution + * of a GraphQL document: + * - UnicodeBOM + * - WhiteSpace + * - LineTerminator + * - Comment + * - Comma + * - BlockString indentation + * + * Note: It is required to have a delimiter character between neighboring + * non-punctuator tokens and this function always uses single space as delimiter. + * + * It is guaranteed that both input and output documents if parsed would result + * in the exact same AST except for nodes location. + * + * Warning: It is guaranteed that this function will always produce stable results. + * However, it's not guaranteed that it will stay the same between different + * releases due to bugfixes or changes in the GraphQL specification. + * + * Query example: + * + * query SomeQuery($foo: String!, $bar: String) { + * someField(foo: $foo, bar: $bar) { + * a + * b { + * c + * d + * } + * } + * } + * + * Becomes: + * + * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}} + * + * SDL example: + * + * """ + * Type description + * """ + * type Foo { + * """ + * Field description + * """ + * bar: String + * } + * + * Becomes: + * + * """Type description""" type Foo{"""Field description""" bar:String} + */ +export function stripIgnoredCharacters(source: string | Source): string; diff --git a/tstypes/utilities/typeComparators.d.ts b/tstypes/utilities/typeComparators.d.ts index ca0cdaf6c2..7de3e00b68 100644 --- a/tstypes/utilities/typeComparators.d.ts +++ b/tstypes/utilities/typeComparators.d.ts @@ -1,9 +1,5 @@ -import { - GraphQLType, - GraphQLCompositeType, - GraphQLAbstractType, -} from '../type/definition'; import { GraphQLSchema } from '../type/schema'; +import { GraphQLType, GraphQLCompositeType } from '../type/definition'; /** * Provided two types, return true if the types are equal (invariant). diff --git a/tstypes/utilities/typeFromAST.d.ts b/tstypes/utilities/typeFromAST.d.ts index 10e467dee9..cf32ac7cee 100644 --- a/tstypes/utilities/typeFromAST.d.ts +++ b/tstypes/utilities/typeFromAST.d.ts @@ -1,17 +1,10 @@ +import { NamedTypeNode, ListTypeNode, NonNullTypeNode } from '../language/ast'; +import { GraphQLSchema } from '../type/schema'; import { - TypeNode, - NamedTypeNode, - ListTypeNode, - NonNullTypeNode, -} from '../language/ast'; -import { - GraphQLType, - GraphQLNullableType, GraphQLNamedType, GraphQLList, GraphQLNonNull, } from '../type/definition'; -import { GraphQLSchema } from '../type/schema'; /** * Given a Schema and an AST node describing a type, return a GraphQLType diff --git a/tstypes/utilities/valueFromAST.d.ts b/tstypes/utilities/valueFromAST.d.ts index 06a130aebf..bef11b75d3 100644 --- a/tstypes/utilities/valueFromAST.d.ts +++ b/tstypes/utilities/valueFromAST.d.ts @@ -1,11 +1,6 @@ import Maybe from '../tsutils/Maybe'; +import { ValueNode } from '../language/ast'; import { GraphQLInputType } from '../type/definition'; -import { - ValueNode, - VariableNode, - ListValueNode, - ObjectValueNode, -} from '../language/ast'; /** * Produces a JavaScript value given a GraphQL Value AST. diff --git a/tstypes/validation/ValidationContext.d.ts b/tstypes/validation/ValidationContext.d.ts index 1576bdc64e..b98c947b7f 100644 --- a/tstypes/validation/ValidationContext.d.ts +++ b/tstypes/validation/ValidationContext.d.ts @@ -1,5 +1,6 @@ import Maybe from '../tsutils/Maybe'; import { GraphQLError } from '../error'; +import { ASTVisitor } from '../language/visitor'; import { DocumentNode, OperationDefinitionNode, @@ -9,6 +10,7 @@ import { FragmentDefinitionNode, } from '../language/ast'; import { GraphQLSchema } from '../type/schema'; +import { GraphQLDirective } from '../type/directives'; import { GraphQLInputType, GraphQLOutputType, @@ -16,9 +18,7 @@ import { GraphQLField, GraphQLArgument, } from '../type/definition'; -import { GraphQLDirective } from '../type/directives'; import { TypeInfo } from '../utilities/TypeInfo'; -import { ASTVisitor } from '../language/visitor'; type NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode; type VariableUsage = { @@ -40,10 +40,22 @@ export class ASTValidationContext { getErrors(): ReadonlyArray; getDocument(): DocumentNode; + + getFragment(name: string): Maybe; + + getFragmentSpreads(node: SelectionSetNode): ReadonlyArray; + + getRecursivelyReferencedFragments( + operation: OperationDefinitionNode, + ): ReadonlyArray; } export class SDLValidationContext extends ASTValidationContext { - constructor(ast: DocumentNode, schema?: Maybe); + constructor( + ast: DocumentNode, + schema: Maybe, + onError?: (err: GraphQLError) => void, + ); getSchema(): Maybe; } @@ -51,24 +63,21 @@ export class SDLValidationContext extends ASTValidationContext { export type SDLValidationRule = (context: SDLValidationContext) => ASTVisitor; export class ValidationContext extends ASTValidationContext { - constructor(schema: GraphQLSchema, ast: DocumentNode, typeInfo: TypeInfo); + constructor( + schema: GraphQLSchema, + ast: DocumentNode, + typeInfo: TypeInfo, + onError?: (err: GraphQLError) => void, + ); getSchema(): GraphQLSchema; - getFragment(name: string): Maybe; - - getFragmentSpreads(node: SelectionSetNode): ReadonlyArray; + getVariableUsages(node: NodeWithSelectionSet): ReadonlyArray; getRecursivelyReferencedFragments( operation: OperationDefinitionNode, ): ReadonlyArray; - getVariableUsages(node: NodeWithSelectionSet): ReadonlyArray; - - getRecursiveVariableUsages( - operation: OperationDefinitionNode, - ): ReadonlyArray; - getType(): Maybe; getParentType(): Maybe; diff --git a/tstypes/validation/index.d.ts b/tstypes/validation/index.d.ts index 3d8f38e80d..3c6d260df6 100644 --- a/tstypes/validation/index.d.ts +++ b/tstypes/validation/index.d.ts @@ -1,6 +1,6 @@ export { validate } from './validate'; -export { ValidationContext } from './ValidationContext'; +export { ValidationContext, ValidationRule } from './ValidationContext'; export { specifiedRules } from './specifiedRules'; diff --git a/tstypes/validation/rules/ExecutableDefinitions.d.ts b/tstypes/validation/rules/ExecutableDefinitions.d.ts index 055bca6e63..e079dea2f0 100644 --- a/tstypes/validation/rules/ExecutableDefinitions.d.ts +++ b/tstypes/validation/rules/ExecutableDefinitions.d.ts @@ -1,5 +1,5 @@ -import { ASTValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ASTValidationContext } from '../ValidationContext'; export function nonExecutableDefinitionMessage(defName: string): string; diff --git a/tstypes/validation/rules/FieldsOnCorrectType.d.ts b/tstypes/validation/rules/FieldsOnCorrectType.d.ts index 38ba3ed846..130cb83d13 100644 --- a/tstypes/validation/rules/FieldsOnCorrectType.d.ts +++ b/tstypes/validation/rules/FieldsOnCorrectType.d.ts @@ -1,5 +1,12 @@ -import { ValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext } from '../ValidationContext'; + +export function undefinedFieldMessage( + fieldName: string, + type: string, + suggestedTypeNames: ReadonlyArray, + suggestedFieldNames: ReadonlyArray, +): string; /** * Fields on correct type diff --git a/tstypes/validation/rules/FragmentsOnCompositeTypes.d.ts b/tstypes/validation/rules/FragmentsOnCompositeTypes.d.ts index f2da30fd00..32bd7c7f7d 100644 --- a/tstypes/validation/rules/FragmentsOnCompositeTypes.d.ts +++ b/tstypes/validation/rules/FragmentsOnCompositeTypes.d.ts @@ -1,5 +1,5 @@ -import { ValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext } from '../ValidationContext'; export function inlineFragmentOnNonCompositeErrorMessage(type: string): string; diff --git a/tstypes/validation/rules/KnownArgumentNames.d.ts b/tstypes/validation/rules/KnownArgumentNames.d.ts index 208f919302..e3869ca72e 100644 --- a/tstypes/validation/rules/KnownArgumentNames.d.ts +++ b/tstypes/validation/rules/KnownArgumentNames.d.ts @@ -5,13 +5,13 @@ export function unknownArgMessage( argName: string, fieldName: string, typeName: string, - suggestedArgs: Array, + suggestedArgs: ReadonlyArray, ): string; export function unknownDirectiveArgMessage( argName: string, directiveName: string, - suggestedArgs: Array, + suggestedArgs: ReadonlyArray, ): string; /** diff --git a/tstypes/validation/rules/KnownDirectives.d.ts b/tstypes/validation/rules/KnownDirectives.d.ts index 8585a80737..ecff9172a2 100644 --- a/tstypes/validation/rules/KnownDirectives.d.ts +++ b/tstypes/validation/rules/KnownDirectives.d.ts @@ -1,5 +1,5 @@ -import { ValidationContext, SDLValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext, SDLValidationContext } from '../ValidationContext'; export function unknownDirectiveMessage(directiveName: string): string; diff --git a/tstypes/validation/rules/KnownFragmentNames.d.ts b/tstypes/validation/rules/KnownFragmentNames.d.ts index 14168e2348..0f91fd895a 100644 --- a/tstypes/validation/rules/KnownFragmentNames.d.ts +++ b/tstypes/validation/rules/KnownFragmentNames.d.ts @@ -1,5 +1,5 @@ -import { ValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext } from '../ValidationContext'; export function unknownFragmentMessage(fragName: string): string; diff --git a/tstypes/validation/rules/KnownTypeNames.d.ts b/tstypes/validation/rules/KnownTypeNames.d.ts index d720269f9b..cc8280db0f 100644 --- a/tstypes/validation/rules/KnownTypeNames.d.ts +++ b/tstypes/validation/rules/KnownTypeNames.d.ts @@ -1,5 +1,5 @@ -import { ValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext } from '../ValidationContext'; export function unknownTypeMessage( typeName: string, diff --git a/tstypes/validation/rules/LoneAnonymousOperation.d.ts b/tstypes/validation/rules/LoneAnonymousOperation.d.ts index 345966ad7d..ed1ce2505b 100644 --- a/tstypes/validation/rules/LoneAnonymousOperation.d.ts +++ b/tstypes/validation/rules/LoneAnonymousOperation.d.ts @@ -1,5 +1,5 @@ -import { ASTValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ASTValidationContext } from '../ValidationContext'; export function anonOperationNotAloneMessage(): string; diff --git a/tstypes/validation/rules/LoneSchemaDefinition.d.ts b/tstypes/validation/rules/LoneSchemaDefinition.d.ts index c2084bb5eb..fab68bee8d 100644 --- a/tstypes/validation/rules/LoneSchemaDefinition.d.ts +++ b/tstypes/validation/rules/LoneSchemaDefinition.d.ts @@ -1,5 +1,5 @@ -import { SDLValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { SDLValidationContext } from '../ValidationContext'; export function schemaDefinitionNotAloneMessage(): string; diff --git a/tstypes/validation/rules/NoFragmentCycles.d.ts b/tstypes/validation/rules/NoFragmentCycles.d.ts index 98e9051722..80eff89fa6 100644 --- a/tstypes/validation/rules/NoFragmentCycles.d.ts +++ b/tstypes/validation/rules/NoFragmentCycles.d.ts @@ -1,9 +1,9 @@ -import { ValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext } from '../ValidationContext'; export function cycleErrorMessage( fragName: string, - spreadNames: Array, + spreadNames: ReadonlyArray, ): string; export function NoFragmentCycles(context: ValidationContext): ASTVisitor; diff --git a/tstypes/validation/rules/NoUndefinedVariables.d.ts b/tstypes/validation/rules/NoUndefinedVariables.d.ts index a8bd4d9d95..54797d3d6c 100644 --- a/tstypes/validation/rules/NoUndefinedVariables.d.ts +++ b/tstypes/validation/rules/NoUndefinedVariables.d.ts @@ -1,6 +1,6 @@ import Maybe from '../../tsutils/Maybe'; -import { ValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext } from '../ValidationContext'; export function undefinedVarMessage( varName: string, diff --git a/tstypes/validation/rules/NoUnusedFragments.d.ts b/tstypes/validation/rules/NoUnusedFragments.d.ts index be44a0cb83..8c9631e8bd 100644 --- a/tstypes/validation/rules/NoUnusedFragments.d.ts +++ b/tstypes/validation/rules/NoUnusedFragments.d.ts @@ -1,5 +1,5 @@ -import { ValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext } from '../ValidationContext'; export function unusedFragMessage(fragName: string): string; diff --git a/tstypes/validation/rules/NoUnusedVariables.d.ts b/tstypes/validation/rules/NoUnusedVariables.d.ts index 4d2c9be1c8..055faa1145 100644 --- a/tstypes/validation/rules/NoUnusedVariables.d.ts +++ b/tstypes/validation/rules/NoUnusedVariables.d.ts @@ -1,6 +1,6 @@ import Maybe from '../../tsutils/Maybe'; -import { ValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext } from '../ValidationContext'; export function unusedVariableMessage( varName: string, diff --git a/tstypes/validation/rules/OverlappingFieldsCanBeMerged.d.ts b/tstypes/validation/rules/OverlappingFieldsCanBeMerged.d.ts index 1288ed1da7..b581ee9c43 100644 --- a/tstypes/validation/rules/OverlappingFieldsCanBeMerged.d.ts +++ b/tstypes/validation/rules/OverlappingFieldsCanBeMerged.d.ts @@ -1,5 +1,5 @@ -import { ValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext } from '../ValidationContext'; export function fieldsConflictMessage( responseName: string, diff --git a/tstypes/validation/rules/PossibleFragmentSpreads.d.ts b/tstypes/validation/rules/PossibleFragmentSpreads.d.ts index 1623fc41d8..cd1a3fc074 100644 --- a/tstypes/validation/rules/PossibleFragmentSpreads.d.ts +++ b/tstypes/validation/rules/PossibleFragmentSpreads.d.ts @@ -1,5 +1,5 @@ -import { ValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext } from '../ValidationContext'; export function typeIncompatibleSpreadMessage( fragName: string, diff --git a/tstypes/validation/rules/PossibleTypeExtensions.d.ts b/tstypes/validation/rules/PossibleTypeExtensions.d.ts new file mode 100644 index 0000000000..0bb4328f19 --- /dev/null +++ b/tstypes/validation/rules/PossibleTypeExtensions.d.ts @@ -0,0 +1,21 @@ +import { ASTVisitor } from '../../language/visitor'; +import { SDLValidationContext } from '../ValidationContext'; + +export function extendingUnknownTypeMessage( + typeName: string, + suggestedTypes: $ReadOnlyArray, +): string; + +export function extendingDifferentTypeKindMessage( + typeName: string, + kind: string, +): string; + +/** + * Possible type extension + * + * A type extension is only valid if the type is defined and has the same kind. + */ +export function PossibleTypeExtensions( + context: SDLValidationContext, +): ASTVisitor; diff --git a/tstypes/validation/rules/ProvidedRequiredArguments.d.ts b/tstypes/validation/rules/ProvidedRequiredArguments.d.ts index a7382f2af7..c1bc4c4683 100644 --- a/tstypes/validation/rules/ProvidedRequiredArguments.d.ts +++ b/tstypes/validation/rules/ProvidedRequiredArguments.d.ts @@ -1,5 +1,5 @@ -import { ValidationContext, SDLValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext, SDLValidationContext } from '../ValidationContext'; export function missingFieldArgMessage( fieldName: string, diff --git a/tstypes/validation/rules/ScalarLeafs.d.ts b/tstypes/validation/rules/ScalarLeafs.d.ts index c16d923811..f01448beef 100644 --- a/tstypes/validation/rules/ScalarLeafs.d.ts +++ b/tstypes/validation/rules/ScalarLeafs.d.ts @@ -1,5 +1,5 @@ -import { ValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext } from '../ValidationContext'; export function noSubselectionAllowedMessage( fieldName: string, diff --git a/tstypes/validation/rules/SingleFieldSubscriptions.d.ts b/tstypes/validation/rules/SingleFieldSubscriptions.d.ts index 8e3d56c3b1..7dbbb23cf3 100644 --- a/tstypes/validation/rules/SingleFieldSubscriptions.d.ts +++ b/tstypes/validation/rules/SingleFieldSubscriptions.d.ts @@ -1,6 +1,6 @@ import Maybe from '../../tsutils/Maybe'; -import { ASTValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ASTValidationContext } from '../ValidationContext'; export function singleFieldOnlyMessage(name: Maybe): string; diff --git a/tstypes/validation/rules/UniqueArgumentNames.d.ts b/tstypes/validation/rules/UniqueArgumentNames.d.ts index f0b4d4adc2..fdd51e1020 100644 --- a/tstypes/validation/rules/UniqueArgumentNames.d.ts +++ b/tstypes/validation/rules/UniqueArgumentNames.d.ts @@ -1,5 +1,5 @@ -import { ASTValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ASTValidationContext } from '../ValidationContext'; export function duplicateArgMessage(argName: string): string; diff --git a/tstypes/validation/rules/UniqueDirectiveNames.d.ts b/tstypes/validation/rules/UniqueDirectiveNames.d.ts new file mode 100644 index 0000000000..3490938491 --- /dev/null +++ b/tstypes/validation/rules/UniqueDirectiveNames.d.ts @@ -0,0 +1,13 @@ +import { ASTVisitor } from '../../language/visitor'; +import { ASTValidationContext } from '../ValidationContext'; + +export function duplicateDirectiveNameMessage(directiveName: string): string; + +export function existedDirectiveNameMessage(directiveName: string): string; + +/** + * Unique directive names + * + * A GraphQL document is only valid if all defined directives have unique names. + */ +export function UniqueDirectiveNames(context: SDLValidationContext): ASTVisitor; diff --git a/tstypes/validation/rules/UniqueDirectivesPerLocation.d.ts b/tstypes/validation/rules/UniqueDirectivesPerLocation.d.ts index 879eea7eeb..02c73123cd 100644 --- a/tstypes/validation/rules/UniqueDirectivesPerLocation.d.ts +++ b/tstypes/validation/rules/UniqueDirectivesPerLocation.d.ts @@ -1,5 +1,5 @@ -import { ASTValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ASTValidationContext } from '../ValidationContext'; export function duplicateDirectiveMessage(directiveName: string): string; diff --git a/tstypes/validation/rules/UniqueEnumValueNames.d.ts b/tstypes/validation/rules/UniqueEnumValueNames.d.ts new file mode 100644 index 0000000000..2f3f654092 --- /dev/null +++ b/tstypes/validation/rules/UniqueEnumValueNames.d.ts @@ -0,0 +1,19 @@ +import { ASTVisitor } from '../../language/visitor'; +import { SDLValidationContext } from '../ValidationContext'; + +export function duplicateEnumValueNameMessage( + typeName: string, + valueName: string, +): string; + +export function existedEnumValueNameMessage( + typeName: string, + valueName: string, +): string; + +/** + * Unique enum value names + * + * A GraphQL enum type is only valid if all its values are uniquely named. + */ +export function UniqueEnumValueNames(context: SDLValidationContext): ASTVisitor; diff --git a/tstypes/validation/rules/UniqueFieldDefinitionNames.d.ts b/tstypes/validation/rules/UniqueFieldDefinitionNames.d.ts new file mode 100644 index 0000000000..11d6e4fb64 --- /dev/null +++ b/tstypes/validation/rules/UniqueFieldDefinitionNames.d.ts @@ -0,0 +1,21 @@ +import { ASTVisitor } from '../../language/visitor'; +import { SDLValidationContext } from '../ValidationContext'; + +export function duplicateFieldDefinitionNameMessage( + typeName: string, + fieldName: string, +): string; + +export function existedFieldDefinitionNameMessage( + typeName: string, + fieldName: string, +): string; + +/** + * Unique field definition names + * + * A GraphQL complex type is only valid if all its fields are uniquely named. + */ +export function UniqueFieldDefinitionNames( + context: SDLValidationContext, +): ASTVisitor; diff --git a/tstypes/validation/rules/UniqueFragmentNames.d.ts b/tstypes/validation/rules/UniqueFragmentNames.d.ts index e849d9fe32..ebd4bb2d6e 100644 --- a/tstypes/validation/rules/UniqueFragmentNames.d.ts +++ b/tstypes/validation/rules/UniqueFragmentNames.d.ts @@ -1,5 +1,5 @@ -import { ASTValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ASTValidationContext } from '../ValidationContext'; export function duplicateFragmentNameMessage(fragName: string): string; diff --git a/tstypes/validation/rules/UniqueInputFieldNames.d.ts b/tstypes/validation/rules/UniqueInputFieldNames.d.ts index d2682fec0b..3894428ca8 100644 --- a/tstypes/validation/rules/UniqueInputFieldNames.d.ts +++ b/tstypes/validation/rules/UniqueInputFieldNames.d.ts @@ -1,5 +1,5 @@ -import { ASTValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ASTValidationContext } from '../ValidationContext'; export function duplicateInputFieldMessage(fieldName: string): string; diff --git a/tstypes/validation/rules/UniqueOperationNames.d.ts b/tstypes/validation/rules/UniqueOperationNames.d.ts index bd31be1ee2..0c6234965a 100644 --- a/tstypes/validation/rules/UniqueOperationNames.d.ts +++ b/tstypes/validation/rules/UniqueOperationNames.d.ts @@ -1,5 +1,5 @@ -import { ASTValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ASTValidationContext } from '../ValidationContext'; export function duplicateOperationNameMessage(operationName: string): string; diff --git a/tstypes/validation/rules/UniqueOperationTypes.d.ts b/tstypes/validation/rules/UniqueOperationTypes.d.ts new file mode 100644 index 0000000000..fef615bbc1 --- /dev/null +++ b/tstypes/validation/rules/UniqueOperationTypes.d.ts @@ -0,0 +1,13 @@ +import { ASTVisitor } from '../../language/visitor'; +import { SDLValidationContext } from '../ValidationContext'; + +export function duplicateOperationTypeMessage(operation: string): string; + +export function existedOperationTypeMessage(operation: string): string; + +/** + * Unique operation types + * + * A GraphQL document is only valid if it has only one type per operation. + */ +export function UniqueOperationTypes(context: SDLValidationContext): ASTVisitor; diff --git a/tstypes/validation/rules/UniqueTypeNames.d.ts b/tstypes/validation/rules/UniqueTypeNames.d.ts new file mode 100644 index 0000000000..8b9e3ad3ab --- /dev/null +++ b/tstypes/validation/rules/UniqueTypeNames.d.ts @@ -0,0 +1,13 @@ +import { ASTVisitor } from '../../language/visitor'; +import { SDLValidationContext } from '../ValidationContext'; + +export function duplicateTypeNameMessage(typeName: string): string; + +export function existedTypeNameMessage(typeName: string): string; + +/** + * Unique type names + * + * A GraphQL document is only valid if all defined types have unique names. + */ +export function UniqueTypeNames(context: SDLValidationContext): ASTVisitor; diff --git a/tstypes/validation/rules/UniqueVariableNames.d.ts b/tstypes/validation/rules/UniqueVariableNames.d.ts index ac81c95f9e..0ed9633804 100644 --- a/tstypes/validation/rules/UniqueVariableNames.d.ts +++ b/tstypes/validation/rules/UniqueVariableNames.d.ts @@ -1,5 +1,5 @@ -import { ASTValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ASTValidationContext } from '../ValidationContext'; export function duplicateVariableMessage(variableName: string): string; diff --git a/tstypes/validation/rules/ValuesOfCorrectType.d.ts b/tstypes/validation/rules/ValuesOfCorrectType.d.ts index 3ef5d6d4ed..9b475cf272 100644 --- a/tstypes/validation/rules/ValuesOfCorrectType.d.ts +++ b/tstypes/validation/rules/ValuesOfCorrectType.d.ts @@ -1,5 +1,5 @@ -import { ValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext } from '../ValidationContext'; export function badValueMessage( typeName: string, @@ -7,6 +7,12 @@ export function badValueMessage( message?: string, ): string; +export function badEnumValueMessage( + typeName: string, + valueName: string, + suggestedValues: ReadonlyArray, +): string; + export function requiredFieldMessage( typeName: string, fieldName: string, @@ -16,7 +22,7 @@ export function requiredFieldMessage( export function unknownFieldMessage( typeName: string, fieldName: string, - message?: string, + suggestedFields: ReadonlyArray, ): string; /** diff --git a/tstypes/validation/rules/VariablesAreInputTypes.d.ts b/tstypes/validation/rules/VariablesAreInputTypes.d.ts index f5103aea20..ace6fea4b5 100644 --- a/tstypes/validation/rules/VariablesAreInputTypes.d.ts +++ b/tstypes/validation/rules/VariablesAreInputTypes.d.ts @@ -1,5 +1,5 @@ -import { ValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext } from '../ValidationContext'; export function nonInputTypeOnVarMessage( variableName: string, diff --git a/tstypes/validation/rules/VariablesInAllowedPosition.d.ts b/tstypes/validation/rules/VariablesInAllowedPosition.d.ts index 84a5dade51..3401c9767f 100644 --- a/tstypes/validation/rules/VariablesInAllowedPosition.d.ts +++ b/tstypes/validation/rules/VariablesInAllowedPosition.d.ts @@ -1,5 +1,5 @@ -import { ValidationContext } from '../ValidationContext'; import { ASTVisitor } from '../../language/visitor'; +import { ValidationContext } from '../ValidationContext'; export function badVarPosMessage( varName: string, diff --git a/tstypes/validation/specifiedRules.d.ts b/tstypes/validation/specifiedRules.d.ts index 98e9e5eb2b..e26fae8980 100644 --- a/tstypes/validation/specifiedRules.d.ts +++ b/tstypes/validation/specifiedRules.d.ts @@ -58,7 +58,10 @@ import { KnownDirectives } from './rules/KnownDirectives'; import { UniqueDirectivesPerLocation } from './rules/UniqueDirectivesPerLocation'; // Spec Section: "Argument Names" -import { KnownArgumentNames } from './rules/KnownArgumentNames'; +import { + KnownArgumentNames, + KnownArgumentNamesOnDirectives, // @internal +} from './rules/KnownArgumentNames'; // Spec Section: "Argument Uniqueness" import { UniqueArgumentNames } from './rules/UniqueArgumentNames'; @@ -67,7 +70,10 @@ import { UniqueArgumentNames } from './rules/UniqueArgumentNames'; import { ValuesOfCorrectType } from './rules/ValuesOfCorrectType'; // Spec Section: "Argument Optionality" -import { ProvidedRequiredArguments } from './rules/ProvidedRequiredArguments'; +import { + ProvidedRequiredArguments, + ProvidedRequiredArgumentsOnDirectives, // @internal +} from './rules/ProvidedRequiredArguments'; // Spec Section: "All Variable Usages Are Allowed" import { VariablesInAllowedPosition } from './rules/VariablesInAllowedPosition'; diff --git a/tstypes/validation/validate.d.ts b/tstypes/validation/validate.d.ts index 9fe20452a9..e1b80ad3cb 100644 --- a/tstypes/validation/validate.d.ts +++ b/tstypes/validation/validate.d.ts @@ -3,6 +3,7 @@ import { DocumentNode } from '../language/ast'; import { GraphQLSchema } from '../type/schema'; import { TypeInfo } from '../utilities/TypeInfo'; import { ValidationRule, SDLValidationRule } from './ValidationContext'; +import Maybe from 'tstypes/tsutils/Maybe'; /** * Implements the "Validation" section of the spec. @@ -25,12 +26,13 @@ export function validate( documentAST: DocumentNode, rules?: ReadonlyArray, typeInfo?: TypeInfo, + options?: { maxErrors?: number }, ): ReadonlyArray; // @internal export function validateSDL( documentAST: DocumentNode, - schemaToExtend?: GraphQLSchema | null, + schemaToExtend?: Maybe, rules?: ReadonlyArray, ): GraphQLError[]; diff --git a/tstypes/version.d.ts b/tstypes/version.d.ts new file mode 100644 index 0000000000..765329b38b --- /dev/null +++ b/tstypes/version.d.ts @@ -0,0 +1,14 @@ +/** + * A string containing the version of the GraphQL.js library + */ +export const version: string; + +/** + * An object containing the components of the GraphQL.js version string + */ +export const versionInfo: { + major: number; + minor: number; + patch: number; + preReleaseTag: number | null; +};