Skip to content

Commit fd50ceb

Browse files
GraphQLField: relax default value of TArgs to any (#3328)
1 parent 52f1754 commit fd50ceb

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

integrationTests/ts/basic-test.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ const queryType: GraphQLObjectType = new GraphQLObjectType({
99
sayHi: {
1010
type: GraphQLString,
1111
args: {
12-
who: { type: GraphQLString },
12+
who: {
13+
type: GraphQLString,
14+
defaultValue: 'World',
15+
},
1316
},
14-
resolve(_root, args) {
15-
return 'Hello ' + (args.who ?? 'World');
17+
resolve(_root, args: { who: string }) {
18+
return 'Hello ' + args.who;
1619
},
1720
},
1821
}),

src/type/definition.ts

+4-16
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ export type GraphQLIsTypeOfFn<TSource, TContext> = (
962962
export type GraphQLFieldResolver<
963963
TSource,
964964
TContext,
965-
TArgs = { [argument: string]: any },
965+
TArgs = any,
966966
TResult = unknown,
967967
> = (
968968
source: TSource,
@@ -996,19 +996,11 @@ export interface GraphQLResolveInfo {
996996
* We've provided these template arguments because this is an open type and
997997
* you may find them useful.
998998
*/
999-
export interface GraphQLFieldExtensions<
1000-
_TSource,
1001-
_TContext,
1002-
_TArgs = { [argName: string]: any },
1003-
> {
999+
export interface GraphQLFieldExtensions<_TSource, _TContext, _TArgs = any> {
10041000
[attributeName: string]: unknown;
10051001
}
10061002

1007-
export interface GraphQLFieldConfig<
1008-
TSource,
1009-
TContext,
1010-
TArgs = { [argument: string]: any },
1011-
> {
1003+
export interface GraphQLFieldConfig<TSource, TContext, TArgs = any> {
10121004
description?: Maybe<string>;
10131005
type: GraphQLOutputType;
10141006
args?: GraphQLFieldConfigArgumentMap;
@@ -1049,11 +1041,7 @@ export type GraphQLFieldConfigMap<TSource, TContext> = ObjMap<
10491041
GraphQLFieldConfig<TSource, TContext>
10501042
>;
10511043

1052-
export interface GraphQLField<
1053-
TSource,
1054-
TContext,
1055-
TArgs = { [argument: string]: any },
1056-
> {
1044+
export interface GraphQLField<TSource, TContext, TArgs = any> {
10571045
name: string;
10581046
description: Maybe<string>;
10591047
type: GraphQLOutputType;

0 commit comments

Comments
 (0)