diff --git a/types/graphql/index.d.ts b/types/graphql/index.d.ts index abaa81294b..74602d80e5 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -17,6 +17,7 @@ // Curtis Layne // Jonathan Cardoso // Pavel Lang +// Mark Caudill // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 diff --git a/types/graphql/type/definition.d.ts b/types/graphql/type/definition.d.ts index 97c16f305c..f491919a13 100644 --- a/types/graphql/type/definition.d.ts +++ b/types/graphql/type/definition.d.ts @@ -140,8 +140,8 @@ export function assertAbstractType(type: any): GraphQLAbstractType; * List Modifier * * A list is a kind of type marker, a wrapping type which points to another - * type. Lists are often created within the context of defining the fields of - * an object type. + * type. Lists are often created within the context of defining the fields + * of an object type. * * Example: * @@ -342,36 +342,48 @@ export interface GraphQLScalarTypeConfig { * }); * */ -export class GraphQLObjectType { +export class GraphQLObjectType< + TSource = any, + TContext = any, + TArgs = { [key: string]: any } +> { name: string; description: Maybe; astNode: Maybe; extensionASTNodes: Maybe>; isTypeOf: Maybe>; - constructor(config: GraphQLObjectTypeConfig); - getFields(): GraphQLFieldMap; + constructor(config: GraphQLObjectTypeConfig); + getFields(): GraphQLFieldMap; getInterfaces(): GraphQLInterfaceType[]; toString(): string; toJSON(): string; inspect(): string; } -export interface GraphQLObjectTypeConfig { +export interface GraphQLObjectTypeConfig< + TSource, + TContext, + TArgs = { [key: string]: any } +> { name: string; interfaces?: Thunk>; - fields: Thunk>; + fields: Thunk>; isTypeOf?: Maybe>; description?: Maybe; astNode?: Maybe; extensionASTNodes?: Maybe>; } -export type GraphQLTypeResolver = ( +export type GraphQLTypeResolver< + TSource, + TContext, + TArgs = { [key: string]: any } +> = ( value: TSource, context: TContext, info: GraphQLResolveInfo -) => MaybePromise | string>>; +) => MaybePromise | string>>; export type GraphQLIsTypeOfFn = ( source: TSource, @@ -423,8 +435,8 @@ export interface GraphQLArgumentConfig { astNode?: Maybe; } -export type GraphQLFieldConfigMap = { - [key: string]: GraphQLFieldConfig; +export type GraphQLFieldConfigMap = { + [key: string]: GraphQLFieldConfig; }; export interface GraphQLField { @@ -449,8 +461,12 @@ export interface GraphQLArgument { export function isRequiredArgument(arg: GraphQLArgument): boolean; -export type GraphQLFieldMap = { - [key: string]: GraphQLField; +export type GraphQLFieldMap< + TSource, + TContext, + TArgs = { [key: string]: any } +> = { + [key: string]: GraphQLField; }; /** @@ -487,15 +503,19 @@ export class GraphQLInterfaceType { inspect(): string; } -export interface GraphQLInterfaceTypeConfig { +export interface GraphQLInterfaceTypeConfig< + TSource, + TContext, + TArgs = { [key: string]: any } +> { name: string; - fields: Thunk>; + fields: Thunk>; /** * Optionally provide a custom type resolver function. If one is not provided, * the default implementation will call `isTypeOf` on each implementing * Object type. */ - resolveType?: Maybe>; + resolveType?: Maybe>; description?: Maybe; astNode?: Maybe; extensionASTNodes?: Maybe>;