From 7b9bfdaf502a460268f7230d837244e68d222cf8 Mon Sep 17 00:00:00 2001 From: Jackson Kearl Date: Fri, 23 Aug 2019 15:36:49 -0700 Subject: [PATCH] Fixup index.d.ts files to reflect Flow (#2118) * Fixup index.d.ts files to refelct Flow * Add back TS version header --- tstypes/index.d.ts | 162 ++++++++++++++++++++++------------ tstypes/language/index.d.ts | 3 + tstypes/type/index.d.ts | 2 + tstypes/validation/index.d.ts | 2 +- tstypes/version.d.ts | 14 +++ 5 files changed, 128 insertions(+), 55 deletions(-) create mode 100644 tstypes/version.d.ts diff --git a/tstypes/index.d.ts b/tstypes/index.d.ts index b5d39379d0..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, @@ -128,10 +160,10 @@ export { GraphQLIsTypeOfFn, GraphQLObjectTypeConfig, GraphQLResolveInfo, + ResponsePath, GraphQLScalarTypeConfig, GraphQLTypeResolver, GraphQLUnionTypeConfig, - GraphQLDirectiveConfig, GraphQLScalarSerializer, GraphQLScalarValueParser, GraphQLScalarLiteralParser, @@ -141,6 +173,12 @@ export { export { Source, getLocation, + // Print source location + printLocation, + printSourceLocation, + // Lex + createLexer, + TokenKind, // Parse parse, parseValue, @@ -152,10 +190,9 @@ export { visitInParallel, visitWithTypeInfo, getVisitFn, + BREAK, Kind, - TokenKind, DirectiveLocation, - BREAK, // Predicates isDefinitionNode, isExecutableDefinitionNode, @@ -166,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, @@ -233,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, @@ -283,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'; @@ -298,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, @@ -313,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. @@ -322,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. @@ -339,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, @@ -348,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, @@ -357,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/index.d.ts b/tstypes/type/index.d.ts index f991561a4d..b6780d8171 100644 --- a/tstypes/type/index.d.ts +++ b/tstypes/type/index.d.ts @@ -1,3 +1,5 @@ +export { Path as ResponsePath } from '../jsutils/Path'; + export { // Predicate isSchema, 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/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; +};