Skip to content

Commit

Permalink
GraphQLField: relax default value of TArgs to any
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Oct 23, 2021
1 parent 52f1754 commit 3fbc1a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
11 changes: 7 additions & 4 deletions integrationTests/ts/basic-test.ts
Original file line number Diff line number Diff line change
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: any, args: { who: string }) {
return 'Hello ' + args.who;
},
},
}),
Expand All @@ -23,7 +26,7 @@ const schema: GraphQLSchema = new GraphQLSchema({ query: queryType });
const result: ExecutionResult = graphqlSync({
schema,
source: `
query helloWho($who: String){
query helloWho($who: String!){
test(who: $who)
}
`,
Expand Down
20 changes: 4 additions & 16 deletions src/type/definition.ts
Original file line number Diff line number Diff line change
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 3fbc1a1

Please sign in to comment.