@@ -6,14 +6,15 @@ import {
66 GraphQLString ,
77 GraphQLBoolean ,
88 getNamedType ,
9+ resolveObjMapThunk ,
910} from 'graphql' ;
1011
1112import type {
1213 GraphQLNamedOutputType ,
1314 GraphQLFieldConfigArgumentMap ,
14- GraphQLFieldConfigMap ,
15+ GraphQLFieldConfig ,
1516 GraphQLFieldResolver ,
16- Thunk ,
17+ ThunkObjMap ,
1718} from 'graphql' ;
1819
1920/**
@@ -79,22 +80,15 @@ export interface ConnectionConfig {
7980 nodeType : GraphQLNamedOutputType | GraphQLNonNull < GraphQLNamedOutputType > ;
8081 resolveNode ?: GraphQLFieldResolver < any , any > ;
8182 resolveCursor ?: GraphQLFieldResolver < any , any > ;
82- edgeFields ?: Thunk < GraphQLFieldConfigMap < any , any > > ;
83- connectionFields ?: Thunk < GraphQLFieldConfigMap < any , any > > ;
83+ edgeFields ?: ThunkObjMap < GraphQLFieldConfig < any , any > > ;
84+ connectionFields ?: ThunkObjMap < GraphQLFieldConfig < any , any > > ;
8485}
8586
8687export interface GraphQLConnectionDefinitions {
8788 edgeType : GraphQLObjectType ;
8889 connectionType : GraphQLObjectType ;
8990}
9091
91- function resolveMaybeThunk < T > ( thingOrThunk : Thunk < T > ) : T {
92- return typeof thingOrThunk === 'function'
93- ? // @ts -expect-error - if it's a function, we assume a thunk without arguments
94- thingOrThunk ( )
95- : thingOrThunk ;
96- }
97-
9892/**
9993 * Returns a GraphQLObjectType for a connection with the given name,
10094 * and whose nodes are of the specified type.
@@ -118,7 +112,7 @@ export function connectionDefinitions(
118112 resolve : config . resolveCursor ,
119113 description : 'A cursor for use in pagination' ,
120114 } ,
121- ...resolveMaybeThunk ( config . edgeFields ?? { } ) ,
115+ ...resolveObjMapThunk ( config . edgeFields ?? { } ) ,
122116 } ) ,
123117 } ) ;
124118
@@ -134,7 +128,7 @@ export function connectionDefinitions(
134128 type : new GraphQLList ( edgeType ) ,
135129 description : 'A list of edges.' ,
136130 } ,
137- ...resolveMaybeThunk ( config . connectionFields ?? { } ) ,
131+ ...resolveObjMapThunk ( config . connectionFields ?? { } ) ,
138132 } ) ,
139133 } ) ;
140134
0 commit comments