@@ -103,6 +103,7 @@ export type ExecutionContext = {|
103
103
operation : OperationDefinitionNode ,
104
104
variableValues : { [ variable : string ] : mixed } ,
105
105
fieldResolver : GraphQLFieldResolver < any , any> ,
106
+ typeResolver : GraphQLTypeResolver < any , any> ,
106
107
errors : Array < GraphQLError > ,
107
108
| } ;
108
109
@@ -125,6 +126,7 @@ export type ExecutionArgs = {|
125
126
variableValues ?: ?{ [ variable : string ] : mixed } ,
126
127
operationName ?: ?string ,
127
128
fieldResolver ?: ?GraphQLFieldResolver < any , any> ,
129
+ typeResolver ?: ?GraphQLTypeResolver < any , any> ,
128
130
| } ;
129
131
130
132
/**
@@ -152,6 +154,7 @@ declare function execute(
152
154
variableValues?: ?{ [ variable : string ] : mixed } ,
153
155
operationName?: ?string,
154
156
fieldResolver?: ?GraphQLFieldResolver< any , any > ,
157
+ typeResolver?: ?GraphQLTypeResolver< any , any > ,
155
158
): MaybePromise< ExecutionResult > ;
156
159
export function execute(
157
160
argsOrSchema,
@@ -161,6 +164,7 @@ export function execute(
161
164
variableValues,
162
165
operationName,
163
166
fieldResolver,
167
+ typeResolver,
164
168
) {
165
169
/* eslint-enable no-redeclare */
166
170
// Extract arguments from object args if provided.
@@ -173,6 +177,7 @@ export function execute(
173
177
argsOrSchema . variableValues ,
174
178
argsOrSchema . operationName ,
175
179
argsOrSchema . fieldResolver ,
180
+ argsOrSchema . typeResolver ,
176
181
)
177
182
: executeImpl (
178
183
argsOrSchema ,
@@ -182,6 +187,7 @@ export function execute(
182
187
variableValues ,
183
188
operationName ,
184
189
fieldResolver ,
190
+ typeResolver ,
185
191
) ;
186
192
}
187
193
@@ -193,6 +199,7 @@ function executeImpl(
193
199
variableValues,
194
200
operationName,
195
201
fieldResolver,
202
+ typeResolver,
196
203
) {
197
204
// If arguments are missing or incorrect, throw an error.
198
205
assertValidExecutionArguments ( schema , document , variableValues ) ;
@@ -207,6 +214,7 @@ function executeImpl(
207
214
variableValues ,
208
215
operationName ,
209
216
fieldResolver ,
217
+ typeResolver ,
210
218
) ;
211
219
212
220
// Return early errors if execution context failed.
@@ -302,6 +310,7 @@ export function buildExecutionContext(
302
310
rawVariableValues: ?ObjMap< mixed > ,
303
311
operationName: ?string,
304
312
fieldResolver: ?GraphQLFieldResolver< any , any > ,
313
+ typeResolver?: ?GraphQLTypeResolver< any , any > ,
305
314
): $ReadOnlyArray< GraphQLError > | ExecutionContext {
306
315
const errors : Array < GraphQLError > = [ ] ;
307
316
let operation : OperationDefinitionNode | void ;
@@ -372,6 +381,7 @@ export function buildExecutionContext(
372
381
operation ,
373
382
variableValues ,
374
383
fieldResolver : fieldResolver || defaultFieldResolver ,
384
+ typeResolver : typeResolver || defaultTypeResolver ,
375
385
errors ,
376
386
} ;
377
387
}
@@ -989,7 +999,7 @@ function completeAbstractValue(
989
999
path: ResponsePath,
990
1000
result: mixed,
991
1001
): MaybePromise< ObjMap < mixed > > {
992
- const resolveTypeFn = returnType . resolveType || defaultResolveType ;
1002
+ const resolveTypeFn = returnType . resolveType || exeContext . typeResolver ;
993
1003
const contextValue = exeContext . contextValue ;
994
1004
const runtimeType = resolveTypeFn ( result , contextValue , info , returnType ) ;
995
1005
@@ -1172,7 +1182,7 @@ function _collectSubfields(
1172
1182
* Otherwise, test each possible type for the abstract type by calling
1173
1183
* isTypeOf for the object being coerced, returning the first type that matches.
1174
1184
*/
1175
- const defaultResolveType : GraphQLTypeResolver < any , * > = function (
1185
+ export const defaultTypeResolver : GraphQLTypeResolver < any , * > = function (
1176
1186
value ,
1177
1187
contextValue ,
1178
1188
info ,
0 commit comments