diff --git a/types/graphql/error/GraphQLError.d.ts b/types/graphql/error/GraphQLError.d.ts index 0be931bee0..ce31564fb1 100644 --- a/types/graphql/error/GraphQLError.d.ts +++ b/types/graphql/error/GraphQLError.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { getLocation } from "../language"; import { ASTNode } from "../language/ast"; import { Source } from "../language/source"; @@ -58,7 +59,7 @@ export class GraphQLError extends Error { /** * The original error thrown from a field resolver during execution. */ - readonly originalError: Error | void; + readonly originalError: Maybe; /** * Extension fields to add to the formatted error. @@ -68,10 +69,10 @@ export class GraphQLError extends Error { constructor( message: string, nodes?: ReadonlyArray | ASTNode | undefined, - source?: Source | void, - positions?: ReadonlyArray | void, - path?: ReadonlyArray | void, - originalError?: Error | void, - extensions?: { [key: string]: any } | void + source?: Maybe, + positions?: Maybe>, + path?: Maybe>, + originalError?: Maybe, + extensions?: Maybe<{ [key: string]: any }> ); } diff --git a/types/graphql/execution/execute.d.ts b/types/graphql/execution/execute.d.ts index 424bb62b5a..7ef4d5ce63 100644 --- a/types/graphql/execution/execute.d.ts +++ b/types/graphql/execution/execute.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLError, locatedError } from "../error"; import { GraphQLSchema } from "../type/schema"; import { @@ -51,9 +52,9 @@ export type ExecutionArgs = { document: DocumentNode; rootValue?: any; contextValue?: any; - variableValues?: { [key: string]: any } | void; - operationName?: string | void; - fieldResolver?: GraphQLFieldResolver | void; + variableValues?: Maybe<{ [key: string]: any }>; + operationName?: Maybe; + fieldResolver?: Maybe>; }; /** @@ -74,9 +75,9 @@ export function execute( document: DocumentNode, rootValue?: any, contextValue?: any, - variableValues?: { [key: string]: any } | void, - operationName?: string | void, - fieldResolver?: GraphQLFieldResolver | void + variableValues?: Maybe<{ [key: string]: any }>, + operationName?: Maybe, + fieldResolver?: Maybe> ): MaybePromise; /** @@ -101,7 +102,7 @@ export function addPath( export function assertValidExecutionArguments( schema: GraphQLSchema, document: DocumentNode, - rawVariableValues: { [key: string]: any } | void + rawVariableValues: Maybe<{ [key: string]: any }> ): void; /** @@ -115,9 +116,9 @@ export function buildExecutionContext( document: DocumentNode, rootValue: any, contextValue: any, - rawVariableValues: { [key: string]: any } | void, - operationName: string | void, - fieldResolver: GraphQLFieldResolver | void + rawVariableValues: Maybe<{ [key: string]: any }>, + operationName: Maybe, + fieldResolver: Maybe> ): ReadonlyArray | ExecutionContext; /** @@ -181,4 +182,4 @@ export function getFieldDef( schema: GraphQLSchema, parentType: GraphQLObjectType, fieldName: string -): GraphQLField | void; +): Maybe>; diff --git a/types/graphql/execution/values.d.ts b/types/graphql/execution/values.d.ts index fb629325e8..e3cb7eb4bc 100644 --- a/types/graphql/execution/values.d.ts +++ b/types/graphql/execution/values.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLError } from "../error"; import { GraphQLInputType, GraphQLField, GraphQLArgument } from "../type/definition"; import { GraphQLDirective } from "../type/directives"; @@ -35,7 +36,7 @@ export function getVariableValues( export function getArgumentValues( def: GraphQLField | GraphQLDirective, node: FieldNode | DirectiveNode, - variableValues?: { [key: string]: any } | void + variableValues?: Maybe<{ [key: string]: any }> ): { [key: string]: any }; /** @@ -54,5 +55,5 @@ export function getDirectiveValues( node: { readonly directives?: ReadonlyArray; }, - variableValues?: { [key: string]: any } | void + variableValues?: Maybe<{ [key: string]: any }> ): undefined | { [key: string]: any }; diff --git a/types/graphql/graphql.d.ts b/types/graphql/graphql.d.ts index 7282ea80f2..59dc3918f1 100644 --- a/types/graphql/graphql.d.ts +++ b/types/graphql/graphql.d.ts @@ -1,3 +1,4 @@ +import Maybe from "./tsutils/Maybe"; import { Source } from "./language/source"; import { GraphQLFieldResolver } from "./type/definition"; import { GraphQLSchema } from "./type/schema"; @@ -38,9 +39,9 @@ export interface GraphQLArgs { source: Source | string; rootValue?: any; contextValue?: any; - variableValues?: { [key: string]: any } | void; - operationName?: string | void; - fieldResolver?: GraphQLFieldResolver | void; + variableValues?: Maybe<{ [key: string]: any }>; + operationName?: Maybe; + fieldResolver?: Maybe>; } export function graphql(args: GraphQLArgs): Promise; @@ -49,9 +50,9 @@ export function graphql( source: Source | string, rootValue?: any, contextValue?: any, - variableValues?: { [key: string]: any } | void, - operationName?: string | void, - fieldResolver?: GraphQLFieldResolver | void + variableValues?: Maybe<{ [key: string]: any }>, + operationName?: Maybe, + fieldResolver?: Maybe> ): Promise; /** @@ -66,7 +67,7 @@ export function graphqlSync( source: Source | string, rootValue?: any, contextValue?: any, - variableValues?: { [key: string]: any } | void, - operationName?: string | void, - fieldResolver?: GraphQLFieldResolver | void + variableValues?: Maybe<{ [key: string]: any }>, + operationName?: Maybe, + fieldResolver?: Maybe> ): ExecutionResult; diff --git a/types/graphql/index.d.ts b/types/graphql/index.d.ts index 68e04d104d..ba9213b7c4 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -13,6 +13,7 @@ // Dylan Stewart // Alessio Dionisi // Divyendu Singh +// Brad Zacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/graphql/language/visitor.d.ts b/types/graphql/language/visitor.d.ts index a137fa318e..be50e6e02e 100644 --- a/types/graphql/language/visitor.d.ts +++ b/types/graphql/language/visitor.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { ASTNode, ASTKindToNode } from "./ast"; import { TypeInfo } from "../utilities/TypeInfo"; @@ -157,4 +158,4 @@ export function visitWithTypeInfo(typeInfo: TypeInfo, visitor: Visitor, kind: string, isLeaving: boolean): VisitFn | void; +export function getVisitFn(visitor: Visitor, kind: string, isLeaving: boolean): Maybe>; diff --git a/types/graphql/subscription/subscribe.d.ts b/types/graphql/subscription/subscribe.d.ts index a9fe6b565e..f5b29ebbb8 100644 --- a/types/graphql/subscription/subscribe.d.ts +++ b/types/graphql/subscription/subscribe.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLSchema } from "../type/schema"; import { DocumentNode } from "../language/ast"; import { GraphQLFieldResolver } from "../type/definition"; @@ -28,10 +29,10 @@ export function subscribe(args: { document: DocumentNode; rootValue?: any; contextValue?: any; - variableValues?: { [key: string]: any } | void; - operationName?: string | void; - fieldResolver?: GraphQLFieldResolver | void; - subscribeFieldResolver?: GraphQLFieldResolver | void; + variableValues?: Maybe<{ [key: string]: any }>; + operationName?: Maybe; + fieldResolver?: Maybe>; + subscribeFieldResolver?: Maybe>; }): Promise | ExecutionResult>; export function subscribe( @@ -39,10 +40,10 @@ export function subscribe( document: DocumentNode, rootValue?: any, contextValue?: any, - variableValues?: { [key: string]: any } | void, - operationName?: string | void, - fieldResolver?: GraphQLFieldResolver | void, - subscribeFieldResolver?: GraphQLFieldResolver | void + variableValues?: Maybe<{ [key: string]: any }>, + operationName?: Maybe, + fieldResolver?: Maybe>, + subscribeFieldResolver?: Maybe> ): Promise | ExecutionResult>; /** @@ -69,6 +70,6 @@ export function createSourceEventStream( rootValue?: any, contextValue?: any, variableValues?: { [key: string]: any }, - operationName?: string | void, - fieldResolver?: GraphQLFieldResolver | void + operationName?: Maybe, + fieldResolver?: Maybe> ): Promise | ExecutionResult>; diff --git a/types/graphql/tsconfig.json b/types/graphql/tsconfig.json index 72f0de0665..3bc66f8bea 100644 --- a/types/graphql/tsconfig.json +++ b/types/graphql/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -21,4 +21,4 @@ "index.d.ts", "graphql-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/graphql/tsutils/Maybe.d.ts b/types/graphql/tsutils/Maybe.d.ts new file mode 100644 index 0000000000..7ad0bc85a4 --- /dev/null +++ b/types/graphql/tsutils/Maybe.d.ts @@ -0,0 +1,4 @@ +// Conveniently represents flow's "Maybe" type https://flow.org/en/docs/types/maybe/ +type Maybe = null | undefined | T + +export default Maybe diff --git a/types/graphql/type/definition.d.ts b/types/graphql/type/definition.d.ts index ed87af50ad..b078acccb1 100644 --- a/types/graphql/type/definition.d.ts +++ b/types/graphql/type/definition.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { MaybePromise } from "../jsutils/MaybePromise"; import { ScalarTypeDefinitionNode, @@ -254,8 +255,8 @@ export type Thunk = (() => T) | T; */ export class GraphQLScalarType { name: string; - description: string | void; - astNode?: ScalarTypeDefinitionNode | void; + description: Maybe; + astNode?: Maybe; constructor(config: GraphQLScalarTypeConfig); // Serializes an internal value to include in a response. @@ -265,7 +266,7 @@ export class GraphQLScalarType { parseValue(value: any): any; // Parses an externally provided literal value to use as an input. - parseLiteral(valueNode: ValueNode, variables?: { [key: string]: any } | void): any; + parseLiteral(valueNode: ValueNode, variables?: Maybe<{ [key: string]: any }>): any; toString(): string; toJSON(): string; @@ -274,11 +275,11 @@ export class GraphQLScalarType { export interface GraphQLScalarTypeConfig { name: string; - description?: string | void; - astNode?: ScalarTypeDefinitionNode | void; - serialize(value: any): TExternal | void; - parseValue?(value: any): TInternal | void; - parseLiteral?(valueNode: ValueNode, variables: { [key: string]: any } | void): TInternal | void; + description?: Maybe; + astNode?: Maybe; + serialize(value: any): Maybe; + parseValue?(value: any): Maybe; + parseLiteral?(valueNode: ValueNode, variables: Maybe<{ [key: string]: any }>): Maybe; } /** @@ -320,10 +321,10 @@ export interface GraphQLScalarTypeConfig { */ export class GraphQLObjectType { name: string; - description: string | void; - astNode: ObjectTypeDefinitionNode | void; - extensionASTNodes: ReadonlyArray | void; - isTypeOf: GraphQLIsTypeOfFn | void; + description: Maybe; + astNode: Maybe; + extensionASTNodes: Maybe>; + isTypeOf: Maybe>; constructor(config: GraphQLObjectTypeConfig); getFields(): GraphQLFieldMap; @@ -335,19 +336,19 @@ export class GraphQLObjectType { export interface GraphQLObjectTypeConfig { name: string; - interfaces?: Thunk; + interfaces?: Thunk>; fields: Thunk>; - isTypeOf?: GraphQLIsTypeOfFn | void; - description?: string | void; - astNode?: ObjectTypeDefinitionNode | void; - extensionASTNodes?: ReadonlyArray | void; + isTypeOf?: Maybe>; + description?: Maybe; + astNode?: Maybe; + extensionASTNodes?: Maybe>; } export type GraphQLTypeResolver = ( value: TSource, context: TContext, info: GraphQLResolveInfo -) => MaybePromise; +) => MaybePromise>; export type GraphQLIsTypeOfFn = ( source: TSource, @@ -385,9 +386,9 @@ export interface GraphQLFieldConfig; subscribe?: GraphQLFieldResolver; - deprecationReason?: string | void; - description?: string | void; - astNode?: FieldDefinitionNode | void; + deprecationReason?: Maybe; + description?: Maybe; + astNode?: Maybe; } export type GraphQLFieldConfigArgumentMap = { [key: string]: GraphQLArgumentConfig }; @@ -395,8 +396,8 @@ export type GraphQLFieldConfigArgumentMap = { [key: string]: GraphQLArgumentConf export interface GraphQLArgumentConfig { type: GraphQLInputType; defaultValue?: any; - description?: string | void; - astNode?: InputValueDefinitionNode | void; + description?: Maybe; + astNode?: Maybe; } export type GraphQLFieldConfigMap = { @@ -405,22 +406,22 @@ export type GraphQLFieldConfigMap = { export interface GraphQLField { name: string; - description: string | void; + description: Maybe; type: GraphQLOutputType; args: GraphQLArgument[]; resolve?: GraphQLFieldResolver; subscribe?: GraphQLFieldResolver; isDeprecated?: boolean; - deprecationReason?: string | void; - astNode?: FieldDefinitionNode | void; + deprecationReason?: Maybe; + astNode?: Maybe; } export interface GraphQLArgument { name: string; type: GraphQLInputType; defaultValue?: any; - description?: string | void; - astNode?: InputValueDefinitionNode | void; + description?: Maybe; + astNode?: Maybe; } export type GraphQLFieldMap = { @@ -447,10 +448,10 @@ export type GraphQLFieldMap = { */ export class GraphQLInterfaceType { name: string; - description: string | void; - astNode?: InterfaceTypeDefinitionNode | void; - extensionASTNodes: ReadonlyArray | void; - resolveType: GraphQLTypeResolver | void; + description: Maybe; + astNode?: Maybe; + extensionASTNodes: Maybe>; + resolveType: Maybe>; constructor(config: GraphQLInterfaceTypeConfig); @@ -469,10 +470,10 @@ export interface GraphQLInterfaceTypeConfig { * the default implementation will call `isTypeOf` on each implementing * Object type. */ - resolveType?: GraphQLTypeResolver | void; - description?: string | void; - astNode?: InterfaceTypeDefinitionNode | void; - extensionASTNodes?: ReadonlyArray | void; + resolveType?: Maybe>; + description?: Maybe; + astNode?: Maybe; + extensionASTNodes?: Maybe>; } /** @@ -500,9 +501,9 @@ export interface GraphQLInterfaceTypeConfig { */ export class GraphQLUnionType { name: string; - description: string | void; - astNode?: UnionTypeDefinitionNode | void; - resolveType: GraphQLTypeResolver | void; + description: Maybe; + astNode?: Maybe; + resolveType: Maybe>; constructor(config: GraphQLUnionTypeConfig); @@ -521,9 +522,9 @@ export interface GraphQLUnionTypeConfig { * the default implementation will call `isTypeOf` on each implementing * Object type. */ - resolveType?: GraphQLTypeResolver | void; - description?: string | void; - astNode?: UnionTypeDefinitionNode | void; + resolveType?: Maybe>; + description?: Maybe; + astNode?: Maybe; } /** @@ -549,15 +550,15 @@ export interface GraphQLUnionTypeConfig { */ export class GraphQLEnumType { name: string; - description: string | void; - astNode: EnumTypeDefinitionNode | void; + description: Maybe; + astNode: Maybe; constructor(config: GraphQLEnumTypeConfig); getValues(): GraphQLEnumValue[]; - getValue(name: string): GraphQLEnumValue | void; - serialize(value: any): string | void; - parseValue(value: any): any; - parseLiteral(valueNode: ValueNode, _variables: { [key: string]: any } | void): any; + getValue(name: string): Maybe; + serialize(value: any): Maybe; + parseValue(value: any): Maybe; + parseLiteral(valueNode: ValueNode, _variables: Maybe<{ [key: string]: any }>): Maybe; toString(): string; toJSON(): string; inspect(): string; @@ -566,25 +567,25 @@ export class GraphQLEnumType { export interface GraphQLEnumTypeConfig { name: string; values: GraphQLEnumValueConfigMap; - description?: string | void; - astNode?: EnumTypeDefinitionNode | void; + description?: Maybe; + astNode?: Maybe; } export type GraphQLEnumValueConfigMap = { [key: string]: GraphQLEnumValueConfig }; export interface GraphQLEnumValueConfig { value?: any; - deprecationReason?: string | void; - description?: string | void; - astNode?: EnumValueDefinitionNode | void; + deprecationReason?: Maybe; + description?: Maybe; + astNode?: Maybe; } export interface GraphQLEnumValue { name: string; - description: string | void; + description: Maybe; isDeprecated?: boolean; - deprecationReason: string | void; - astNode?: EnumValueDefinitionNode | void; + deprecationReason: Maybe; + astNode?: Maybe; value: any; } @@ -610,8 +611,8 @@ export interface GraphQLEnumValue { */ export class GraphQLInputObjectType { name: string; - description: string | void; - astNode: InputObjectTypeDefinitionNode | void; + description: Maybe; + astNode: Maybe; constructor(config: GraphQLInputObjectTypeConfig); getFields(): GraphQLInputFieldMap; toString(): string; @@ -622,15 +623,15 @@ export class GraphQLInputObjectType { export interface GraphQLInputObjectTypeConfig { name: string; fields: Thunk; - description?: string | void; - astNode?: InputObjectTypeDefinitionNode | void; + description?: Maybe; + astNode?: Maybe; } export interface GraphQLInputFieldConfig { type: GraphQLInputType; defaultValue?: any; - description?: string | void; - astNode?: InputValueDefinitionNode | void; + description?: Maybe; + astNode?: Maybe; } export type GraphQLInputFieldConfigMap = { @@ -641,8 +642,8 @@ export interface GraphQLInputField { name: string; type: GraphQLInputType; defaultValue?: any; - description?: string | void; - astNode?: InputValueDefinitionNode | void; + description?: Maybe; + astNode?: Maybe; } export type GraphQLInputFieldMap = { [key: string]: GraphQLInputField }; diff --git a/types/graphql/type/directives.d.ts b/types/graphql/type/directives.d.ts index f6e19f674d..ca9e947640 100644 --- a/types/graphql/type/directives.d.ts +++ b/types/graphql/type/directives.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLFieldConfigArgumentMap, GraphQLArgument } from "./definition"; import { DirectiveDefinitionNode } from "../language/ast"; import { DirectiveLocationEnum } from "../language/directiveLocation"; @@ -13,20 +14,20 @@ export function isDirective(directive: any): directive is GraphQLDirective; */ export class GraphQLDirective { name: string; - description: string | void; + description: Maybe; locations: DirectiveLocationEnum[]; args: GraphQLArgument[]; - astNode: DirectiveDefinitionNode | void; + astNode: Maybe; constructor(config: GraphQLDirectiveConfig); } export interface GraphQLDirectiveConfig { name: string; - description?: string | void; + description?: Maybe; locations: DirectiveLocationEnum[]; - args?: GraphQLFieldConfigArgumentMap | void; - astNode?: DirectiveDefinitionNode | void; + args?: Maybe; + astNode?: Maybe; } /** diff --git a/types/graphql/type/schema.d.ts b/types/graphql/type/schema.d.ts index a7bb94f5c5..b5ddc9d8d4 100644 --- a/types/graphql/type/schema.d.ts +++ b/types/graphql/type/schema.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLObjectType } from "./definition"; import { GraphQLType, GraphQLNamedType, GraphQLAbstractType } from "./definition"; import { SchemaDefinitionNode } from "../language/ast"; @@ -35,21 +36,21 @@ export function isSchema(schema: any): schema is GraphQLSchema; * */ export class GraphQLSchema { - astNode: SchemaDefinitionNode | void; + astNode: Maybe; constructor(config: GraphQLSchemaConfig); - getQueryType(): GraphQLObjectType | void; - getMutationType(): GraphQLObjectType | void; - getSubscriptionType(): GraphQLObjectType | void; + getQueryType(): Maybe; + getMutationType(): Maybe; + getSubscriptionType(): Maybe; getTypeMap(): TypeMap; - getType(name: string): GraphQLNamedType | void; + getType(name: string): Maybe; getPossibleTypes(abstractType: GraphQLAbstractType): ReadonlyArray; isPossibleType(abstractType: GraphQLAbstractType, possibleType: GraphQLObjectType): boolean; getDirectives(): ReadonlyArray; - getDirective(name: string): GraphQLDirective | void; + getDirective(name: string): Maybe; } type TypeMap = { [key: string]: GraphQLNamedType }; @@ -72,14 +73,14 @@ export interface GraphQLSchemaValidationOptions { * This option is provided to ease adoption and may be removed in a future * major release. */ - allowedLegacyNames?: ReadonlyArray | void; + allowedLegacyNames?: Maybe>; } export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions { - query: GraphQLObjectType | void; - mutation?: GraphQLObjectType | void; - subscription?: GraphQLObjectType | void; - types?: GraphQLNamedType[] | void; - directives?: GraphQLDirective[] | void; - astNode?: SchemaDefinitionNode | void; + query: Maybe; + mutation?: Maybe; + subscription?: Maybe; + types?: Maybe; + directives?: Maybe; + astNode?: Maybe; } diff --git a/types/graphql/utilities/TypeInfo.d.ts b/types/graphql/utilities/TypeInfo.d.ts index 1c2f139642..826704a52b 100644 --- a/types/graphql/utilities/TypeInfo.d.ts +++ b/types/graphql/utilities/TypeInfo.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLSchema } from "../type/schema"; import { GraphQLOutputType, @@ -28,14 +29,15 @@ export class TypeInfo { initialType?: GraphQLType ); - getType(): GraphQLOutputType | void; - getParentType(): GraphQLCompositeType | void; - getInputType(): GraphQLInputType | void; - getParentInputType(): GraphQLInputType | void; - getFieldDef(): GraphQLField | void; - getDirective(): GraphQLDirective | void; - getArgument(): GraphQLArgument | void; - getEnumValue(): GraphQLEnumValue | void; + getType(): Maybe; + getParentType(): Maybe; + getInputType(): Maybe; + getParentInputType(): Maybe; + getFieldDef(): GraphQLField>; + getDefaultValue(): Maybe; + getDirective(): Maybe; + getArgument(): Maybe; + getEnumValue(): Maybe; enter(node: ASTNode): any; leave(node: ASTNode): any; } @@ -44,4 +46,4 @@ type getFieldDef = ( schema: GraphQLSchema, parentType: GraphQLType, fieldNode: FieldNode -) => GraphQLField | void; +) => Maybe>; diff --git a/types/graphql/utilities/astFromValue.d.ts b/types/graphql/utilities/astFromValue.d.ts index 9c2198e6d6..e6c9f1ba6c 100644 --- a/types/graphql/utilities/astFromValue.d.ts +++ b/types/graphql/utilities/astFromValue.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { ValueNode } from "../language/ast"; import { GraphQLInputType } from "../type/definition"; @@ -18,4 +19,4 @@ import { GraphQLInputType } from "../type/definition"; * | null | NullValue | * */ -export function astFromValue(value: any, type: GraphQLInputType): ValueNode | void; +export function astFromValue(value: any, type: GraphQLInputType): Maybe; diff --git a/types/graphql/utilities/buildASTSchema.d.ts b/types/graphql/utilities/buildASTSchema.d.ts index ebff50b4f7..e2406c7ee1 100644 --- a/types/graphql/utilities/buildASTSchema.d.ts +++ b/types/graphql/utilities/buildASTSchema.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { DocumentNode, Location, @@ -47,7 +48,7 @@ type TypeDefinitionsMap = { [key: string]: TypeDefinitionNode }; type TypeResolver = (typeRef: NamedTypeNode) => GraphQLNamedType; export class ASTDefinitionBuilder { - constructor(typeDefinitionsMap: TypeDefinitionsMap, options: BuildSchemaOptions | void, resolveType: TypeResolver); + constructor(typeDefinitionsMap: TypeDefinitionsMap, options: Maybe, resolveType: TypeResolver); buildTypes(nodes: ReadonlyArray): Array; @@ -69,7 +70,7 @@ export class ASTDefinitionBuilder { */ export function getDescription( node: { readonly description?: StringValueNode; readonly loc?: Location }, - options: BuildSchemaOptions | void + options: Maybe ): string | undefined; /** diff --git a/types/graphql/utilities/getOperationAST.d.ts b/types/graphql/utilities/getOperationAST.d.ts index 81e9bd4cbe..a36cfa139c 100644 --- a/types/graphql/utilities/getOperationAST.d.ts +++ b/types/graphql/utilities/getOperationAST.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { DocumentNode, OperationDefinitionNode } from "../language/ast"; /** @@ -7,5 +8,5 @@ import { DocumentNode, OperationDefinitionNode } from "../language/ast"; */ export function getOperationAST( documentAST: DocumentNode, - operationName: string | void -): OperationDefinitionNode | void; + operationName: Maybe +): Maybe; diff --git a/types/graphql/utilities/introspectionQuery.d.ts b/types/graphql/utilities/introspectionQuery.d.ts index 750fe0d99c..f2172595f8 100644 --- a/types/graphql/utilities/introspectionQuery.d.ts +++ b/types/graphql/utilities/introspectionQuery.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { DirectiveLocationEnum } from "../language/directiveLocation"; export interface IntrospectionOptions { @@ -16,8 +17,8 @@ export interface IntrospectionQuery { export interface IntrospectionSchema { readonly queryType: IntrospectionNamedTypeRef; - readonly mutationType: IntrospectionNamedTypeRef | void; - readonly subscriptionType: IntrospectionNamedTypeRef | void; + readonly mutationType: Maybe>; + readonly subscriptionType: Maybe>; readonly types: ReadonlyArray; readonly directives: ReadonlyArray; } @@ -42,13 +43,13 @@ export type IntrospectionInputType = IntrospectionScalarType | IntrospectionEnum export interface IntrospectionScalarType { readonly kind: "SCALAR"; readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; } export interface IntrospectionObjectType { readonly kind: "OBJECT"; readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly fields: ReadonlyArray; readonly interfaces: ReadonlyArray>; } @@ -56,7 +57,7 @@ export interface IntrospectionObjectType { export interface IntrospectionInterfaceType { readonly kind: "INTERFACE"; readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly fields: ReadonlyArray; readonly possibleTypes: ReadonlyArray>; } @@ -64,21 +65,21 @@ export interface IntrospectionInterfaceType { export interface IntrospectionUnionType { readonly kind: "UNION"; readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly possibleTypes: ReadonlyArray>; } export interface IntrospectionEnumType { readonly kind: "ENUM"; readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly enumValues: ReadonlyArray; } export interface IntrospectionInputObjectType { readonly kind: "INPUT_OBJECT"; readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly inputFields: ReadonlyArray; } @@ -114,30 +115,30 @@ export interface IntrospectionNamedTypeRef; readonly args: ReadonlyArray; readonly type: IntrospectionOutputTypeRef; readonly isDeprecated: boolean; - readonly deprecationReason?: string | void; + readonly deprecationReason?: Maybe; } export interface IntrospectionInputValue { readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly type: IntrospectionInputTypeRef; - readonly defaultValue?: string | void; + readonly defaultValue?: Maybe; } export interface IntrospectionEnumValue { readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly isDeprecated: boolean; - readonly deprecationReason?: string | void; + readonly deprecationReason?: Maybe; } export interface IntrospectionDirective { readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly locations: ReadonlyArray; readonly args: ReadonlyArray; } diff --git a/types/graphql/utilities/valueFromAST.d.ts b/types/graphql/utilities/valueFromAST.d.ts index cd67108aad..c95eca9002 100644 --- a/types/graphql/utilities/valueFromAST.d.ts +++ b/types/graphql/utilities/valueFromAST.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLInputType } from "../type/definition"; import { ValueNode, VariableNode, ListValueNode, ObjectValueNode } from "../language/ast"; @@ -22,7 +23,7 @@ import { ValueNode, VariableNode, ListValueNode, ObjectValueNode } from "../lang * */ export function valueFromAST( - valueNode: ValueNode | void, + valueNode: Maybe, type: GraphQLInputType, - variables?: { [key: string]: any } | void + variables?: Maybe<{ [key: string]: any }> ): any; diff --git a/types/graphql/utilities/valueFromASTUntyped.d.ts b/types/graphql/utilities/valueFromASTUntyped.d.ts index 98d3137694..4ca58ca867 100644 --- a/types/graphql/utilities/valueFromASTUntyped.d.ts +++ b/types/graphql/utilities/valueFromASTUntyped.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { ValueNode } from "../language/ast"; /** @@ -16,4 +17,4 @@ import { ValueNode } from "../language/ast"; * | Null | null | * */ -export function valueFromASTUntyped(valueNode: ValueNode, variables?: { [key: string]: any } | void): any; +export function valueFromASTUntyped(valueNode: ValueNode, variables?: Maybe<{ [key: string]: any }>): any; diff --git a/types/graphql/validation/ValidationContext.d.ts b/types/graphql/validation/ValidationContext.d.ts index 0f8a4ea8f7..24049decdf 100644 --- a/types/graphql/validation/ValidationContext.d.ts +++ b/types/graphql/validation/ValidationContext.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLError } from "../error"; import { DocumentNode, @@ -19,7 +20,11 @@ import { GraphQLDirective } from "../type/directives"; import { TypeInfo } from "../utilities/TypeInfo"; type NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode; -type VariableUsage = { node: VariableNode; type: GraphQLInputType | void }; +type VariableUsage = { + readonly node: VariableNode; + readonly type: Maybe; + readonly defaultValue: Maybe; +}; /** * An instance of this class is passed as the "this" context to all validators, @@ -37,7 +42,7 @@ export default class ValidationContext { getDocument(): DocumentNode; - getFragment(name: string): FragmentDefinitionNode | void; + getFragment(name: string): Maybe; getFragmentSpreads(node: SelectionSetNode): ReadonlyArray; @@ -47,17 +52,17 @@ export default class ValidationContext { getRecursiveVariableUsages(operation: OperationDefinitionNode): ReadonlyArray; - getType(): GraphQLOutputType | void; + getType(): Maybe; - getParentType(): GraphQLCompositeType | void; + getParentType(): Maybe; - getInputType(): GraphQLInputType | void; + getInputType(): Maybe; - getParentInputType(): GraphQLInputType | void; + getParentInputType(): Maybe; - getFieldDef(): GraphQLField | void; + getFieldDef(): Maybe>; - getDirective(): GraphQLDirective | void; + getDirective(): Maybe; - getArgument(): GraphQLArgument | void; + getArgument(): Maybe; } diff --git a/types/graphql/validation/rules/NoUndefinedVariables.d.ts b/types/graphql/validation/rules/NoUndefinedVariables.d.ts index 611ad01a9b..f340b41ad8 100644 --- a/types/graphql/validation/rules/NoUndefinedVariables.d.ts +++ b/types/graphql/validation/rules/NoUndefinedVariables.d.ts @@ -1,7 +1,8 @@ +import Maybe from "../../tsutils/Maybe"; import ValidationContext from "../ValidationContext"; import { ASTVisitor } from "../../language/visitor"; -export function undefinedVarMessage(varName: string, opName: string | void): string; +export function undefinedVarMessage(varName: string, opName: Maybe): string; /** * No undefined variables diff --git a/types/graphql/validation/rules/NoUnusedVariables.d.ts b/types/graphql/validation/rules/NoUnusedVariables.d.ts index 10282cdacd..1846995a1f 100644 --- a/types/graphql/validation/rules/NoUnusedVariables.d.ts +++ b/types/graphql/validation/rules/NoUnusedVariables.d.ts @@ -1,7 +1,8 @@ +import Maybe from "../../tsutils/Maybe"; import ValidationContext from "../ValidationContext"; import { ASTVisitor } from "../../language/visitor"; -export function unusedVariableMessage(varName: string, opName: string | void): string; +export function unusedVariableMessage(varName: string, opName: Maybe): string; /** * No unused variables diff --git a/types/graphql/validation/rules/SingleFieldSubscriptions.d.ts b/types/graphql/validation/rules/SingleFieldSubscriptions.d.ts index fef0869710..54b1fec36a 100644 --- a/types/graphql/validation/rules/SingleFieldSubscriptions.d.ts +++ b/types/graphql/validation/rules/SingleFieldSubscriptions.d.ts @@ -1,7 +1,8 @@ +import Maybe from "../../tsutils/Maybe"; import ValidationContext from "../ValidationContext"; import { ASTVisitor } from "../../language/visitor"; -export function singleFieldOnlyMessage(name: string | void): string; +export function singleFieldOnlyMessage(name: Maybe): string; /** * Subscriptions must only include one field.