mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #32694 from mc0/define-graphql-args
feat(graphql): add TArgs generic to more graphql types
This commit is contained in:
Vendored
+1
@@ -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
|
||||
|
||||
|
||||
Vendored
+36
-16
@@ -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<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,
|
||||
@@ -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 }> {
|
||||
@@ -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>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -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>>;
|
||||
|
||||
Reference in New Issue
Block a user