Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions types/graphql/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// Curtis Layne <https://github.com/clayne11>
// Jonathan Cardoso <https://github.com/JCMais>
// Pavel Lang <https://github.com/langpavel>
// Mark Caudill <https://github.com/mc0>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6

Expand Down
52 changes: 36 additions & 16 deletions types/graphql/type/definition.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
Expand Down Expand Up @@ -342,36 +342,48 @@ export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
* });
*
*/
export class GraphQLObjectType<TSource = any, TContext = any> {
export class GraphQLObjectType<
TSource = any,
TContext = any,
TArgs = { [key: string]: any }
> {
name: string;
description: Maybe<string>;
astNode: Maybe<ObjectTypeDefinitionNode>;
extensionASTNodes: Maybe<ReadonlyArray<ObjectTypeExtensionNode>>;
isTypeOf: Maybe<GraphQLIsTypeOfFn<TSource, TContext>>;

constructor(config: GraphQLObjectTypeConfig<TSource, TContext>);
getFields(): GraphQLFieldMap<any, TContext>;
constructor(config: GraphQLObjectTypeConfig<TSource, TContext, TArgs>);
getFields(): GraphQLFieldMap<any, TContext, TArgs>;
getInterfaces(): GraphQLInterfaceType[];
toString(): string;
toJSON(): string;
inspect(): string;
}

export interface GraphQLObjectTypeConfig<TSource, TContext> {
export interface GraphQLObjectTypeConfig<
TSource,
TContext,
TArgs = { [key: string]: any }
> {
name: string;
interfaces?: Thunk<Maybe<GraphQLInterfaceType[]>>;
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext>>;
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext, TArgs>>;
isTypeOf?: Maybe<GraphQLIsTypeOfFn<TSource, TContext>>;
description?: Maybe<string>;
astNode?: Maybe<ObjectTypeDefinitionNode>;
extensionASTNodes?: Maybe<ReadonlyArray<ObjectTypeExtensionNode>>;
}

export type GraphQLTypeResolver<TSource, TContext> = (
export type GraphQLTypeResolver<
TSource,
TContext,
TArgs = { [key: string]: any }
> = (
value: TSource,
context: TContext,
info: GraphQLResolveInfo
) => MaybePromise<Maybe<GraphQLObjectType<TSource, TContext> | string>>;
) => MaybePromise<Maybe<GraphQLObjectType<TSource, TContext, TArgs> | string>>;

export type GraphQLIsTypeOfFn<TSource, TContext> = (
source: TSource,
Expand Down Expand Up @@ -423,8 +435,8 @@ export interface GraphQLArgumentConfig {
astNode?: Maybe<InputValueDefinitionNode>;
}

export type GraphQLFieldConfigMap<TSource, TContext> = {
[key: string]: GraphQLFieldConfig<TSource, TContext>;
export type GraphQLFieldConfigMap<TSource, TContext, TArgs = { [key: string]: any }> = {
[key: string]: GraphQLFieldConfig<TSource, TContext, TArgs>;
};

export interface GraphQLField<TSource, TContext, TArgs = { [key: string]: any }> {
Expand All @@ -449,8 +461,12 @@ export interface GraphQLArgument {

export function isRequiredArgument(arg: GraphQLArgument): boolean;

export type GraphQLFieldMap<TSource, TContext> = {
[key: string]: GraphQLField<TSource, TContext>;
export type GraphQLFieldMap<
TSource,
TContext,
TArgs = { [key: string]: any }
> = {
[key: string]: GraphQLField<TSource, TContext, TArgs>;
};

/**
Expand Down Expand Up @@ -487,15 +503,19 @@ export class GraphQLInterfaceType {
inspect(): string;
}

export interface GraphQLInterfaceTypeConfig<TSource, TContext> {
export interface GraphQLInterfaceTypeConfig<
TSource,
TContext,
TArgs = { [key: string]: any }
> {
name: string;
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext>>;
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext, TArgs>>;
/**
* 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<GraphQLTypeResolver<TSource, TContext>>;
resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext, TArgs>>;
description?: Maybe<string>;
astNode?: Maybe<InterfaceTypeDefinitionNode>;
extensionASTNodes?: Maybe<ReadonlyArray<InterfaceTypeExtensionNode>>;
Expand Down