Skip to content

Commit 3848c75

Browse files
tgriesserleebyron
authored andcommitted
Allow optionally specifying Args on GraphQLFieldResolver (#1197)
1 parent 80aae99 commit 3848c75

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/type/definition.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -714,9 +714,13 @@ export type GraphQLIsTypeOfFn<TSource, TContext> = (
714714
info: GraphQLResolveInfo,
715715
) => MaybePromise<boolean>;
716716

717-
export type GraphQLFieldResolver<TSource, TContext> = (
717+
export type GraphQLFieldResolver<
718+
TSource,
719+
TContext,
720+
TArgs = { [argument: string]: any },
721+
> = (
718722
source: TSource,
719-
args: { [argument: string]: any },
723+
args: TArgs,
720724
context: TContext,
721725
info: GraphQLResolveInfo,
722726
) => mixed;
@@ -739,11 +743,15 @@ export type ResponsePath = {|
739743
+key: string | number,
740744
|};
741745

742-
export type GraphQLFieldConfig<TSource, TContext> = {
746+
export type GraphQLFieldConfig<
747+
TSource,
748+
TContext,
749+
TArgs = { [argument: string]: any },
750+
> = {
743751
type: GraphQLOutputType,
744752
args?: GraphQLFieldConfigArgumentMap,
745-
resolve?: GraphQLFieldResolver<TSource, TContext>,
746-
subscribe?: GraphQLFieldResolver<TSource, TContext>,
753+
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>,
754+
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>,
747755
deprecationReason?: ?string,
748756
description?: ?string,
749757
astNode?: ?FieldDefinitionNode,
@@ -762,13 +770,17 @@ export type GraphQLFieldConfigMap<TSource, TContext> = ObjMap<
762770
GraphQLFieldConfig<TSource, TContext>,
763771
>;
764772

765-
export type GraphQLField<TSource, TContext> = {
773+
export type GraphQLField<
774+
TSource,
775+
TContext,
776+
TArgs = { [argument: string]: any },
777+
> = {
766778
name: string,
767779
description: ?string,
768780
type: GraphQLOutputType,
769781
args: Array<GraphQLArgument>,
770-
resolve?: GraphQLFieldResolver<TSource, TContext>,
771-
subscribe?: GraphQLFieldResolver<TSource, TContext>,
782+
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>,
783+
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>,
772784
isDeprecated?: boolean,
773785
deprecationReason?: ?string,
774786
astNode?: ?FieldDefinitionNode,

0 commit comments

Comments
 (0)