Skip to content

Commit

Permalink
GraphQLField: relax default value of TArgs to any
Browse files Browse the repository at this point in the history
Fixes #2152
Fixes #2829
  • Loading branch information
IvanGoncharov committed Oct 23, 2021
1 parent 52f1754 commit a453f21
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
9 changes: 6 additions & 3 deletions integrationTests/ts/basic-test.ts
Expand Up @@ -9,10 +9,13 @@ const queryType: GraphQLObjectType = new GraphQLObjectType({
sayHi: {
type: GraphQLString,
args: {
who: { type: GraphQLString },
who: {
type: GraphQLString,
defaultValue: 'World',
},
},
resolve(_root, args) {
return 'Hello ' + (args.who ?? 'World');
resolve(_root, args: { who: string }) {
return 'Hello ' + args.who;
},
},
}),
Expand Down
20 changes: 4 additions & 16 deletions src/type/definition.ts
Expand Up @@ -962,7 +962,7 @@ export type GraphQLIsTypeOfFn<TSource, TContext> = (
export type GraphQLFieldResolver<
TSource,
TContext,
TArgs = { [argument: string]: any },
TArgs = any,
TResult = unknown,
> = (
source: TSource,
Expand Down Expand Up @@ -996,19 +996,11 @@ export interface GraphQLResolveInfo {
* We've provided these template arguments because this is an open type and
* you may find them useful.
*/
export interface GraphQLFieldExtensions<
_TSource,
_TContext,
_TArgs = { [argName: string]: any },
> {
export interface GraphQLFieldExtensions<_TSource, _TContext, _TArgs = any> {
[attributeName: string]: unknown;
}

export interface GraphQLFieldConfig<
TSource,
TContext,
TArgs = { [argument: string]: any },
> {
export interface GraphQLFieldConfig<TSource, TContext, TArgs = any> {
description?: Maybe<string>;
type: GraphQLOutputType;
args?: GraphQLFieldConfigArgumentMap;
Expand Down Expand Up @@ -1049,11 +1041,7 @@ export type GraphQLFieldConfigMap<TSource, TContext> = ObjMap<
GraphQLFieldConfig<TSource, TContext>
>;

export interface GraphQLField<
TSource,
TContext,
TArgs = { [argument: string]: any },
> {
export interface GraphQLField<TSource, TContext, TArgs = any> {
name: string;
description: Maybe<string>;
type: GraphQLOutputType;
Expand Down

0 comments on commit a453f21

Please sign in to comment.