@@ -55,7 +55,7 @@ type AuthOptions = {
55
55
56
56
type GetResolverParams < TSource , TContext , TArgs > = {
57
57
operation : Operation
58
- argsFromLink ?: { [ key : string ] : string }
58
+ argsFromLink ?: { [ key : string ] : any }
59
59
payloadName ?: string
60
60
responseName ?: string
61
61
data : PreprocessingData < TSource , TContext , TArgs >
@@ -65,6 +65,14 @@ type GetResolverParams<TSource, TContext, TArgs> = {
65
65
fetch : typeof crossFetch
66
66
}
67
67
68
+ type inferLinkArgumentsParam < TSource , TContext , TArgs > = {
69
+ paramName : string
70
+ value : any
71
+ resolveData : Partial < ResolveData < TSource , TContext , TArgs > >
72
+ source : TSource
73
+ args : TArgs
74
+ }
75
+
68
76
type GetSubscribeParams < TSource , TContext , TArgs > = {
69
77
operation : Operation
70
78
argsFromLink ?: { [ key : string ] : string }
@@ -325,7 +333,7 @@ export function getPublishResolver<TSource, TContext, TArgs>({
325
333
}
326
334
327
335
/**
328
- * Returns values for link arguments, also covers the cases for
336
+ * Returns values for link arguments, also covers the cases for
329
337
* if the link parameter contains constants that are appended to the link parameter
330
338
*
331
339
* e.g. instead of:
@@ -334,15 +342,23 @@ export function getPublishResolver<TSource, TContext, TArgs>({
334
342
* it could be:
335
343
* abc_{$response.body#/employerId}
336
344
*/
337
- function inferLinkArguments ( paramName , value , resolveData , source , args ) {
345
+ function inferLinkArguments < TSource , TContext , TArgs > ( {
346
+ paramName,
347
+ value,
348
+ resolveData,
349
+ source,
350
+ args
351
+ } : inferLinkArgumentsParam < TSource , TContext , TArgs > ) {
338
352
if ( Object . prototype . toString . call ( value ) === '[object Object]' ) {
339
353
return Object . entries ( value ) . reduce ( ( acc , [ key , value ] ) => {
340
- acc [ key ] = inferLinkArguments ( paramName , value , resolveData , source , args )
354
+ acc [ key ] = inferLinkArguments ( { paramName, value, resolveData, source, args} )
341
355
return acc
342
356
} , { } )
343
357
}
344
358
345
- if ( value . search ( / { | } / ) === - 1 ) {
359
+ if ( typeof value !== 'string' ) {
360
+ return value
361
+ } else if ( value . search ( / { | } / ) === - 1 ) {
346
362
return isRuntimeExpression ( value )
347
363
? resolveRuntimeExpression ( paramName , value , resolveData , source , args )
348
364
: value
@@ -476,7 +492,7 @@ export function getResolver<TSource, TContext, TArgs>({
476
492
477
493
let value = argsFromLink [ paramName ]
478
494
479
- args [ saneParamName ] = inferLinkArguments ( paramName , value , resolveData , source , args )
495
+ args [ saneParamName ] = inferLinkArguments ( { paramName, value, resolveData, source, args} )
480
496
}
481
497
482
498
// Stored used parameters to future requests:
0 commit comments