@@ -55,7 +55,7 @@ type AuthOptions = {
5555
5656type GetResolverParams < TSource , TContext , TArgs > = {
5757 operation : Operation
58- argsFromLink ?: { [ key : string ] : string }
58+ argsFromLink ?: { [ key : string ] : any }
5959 payloadName ?: string
6060 responseName ?: string
6161 data : PreprocessingData < TSource , TContext , TArgs >
@@ -65,6 +65,14 @@ type GetResolverParams<TSource, TContext, TArgs> = {
6565 fetch : typeof crossFetch
6666}
6767
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+
6876type GetSubscribeParams < TSource , TContext , TArgs > = {
6977 operation : Operation
7078 argsFromLink ?: { [ key : string ] : string }
@@ -325,7 +333,7 @@ export function getPublishResolver<TSource, TContext, TArgs>({
325333}
326334
327335/**
328- * Returns values for link arguments, also covers the cases for
336+ * Returns values for link arguments, also covers the cases for
329337 * if the link parameter contains constants that are appended to the link parameter
330338 *
331339 * e.g. instead of:
@@ -334,15 +342,23 @@ export function getPublishResolver<TSource, TContext, TArgs>({
334342 * it could be:
335343 * abc_{$response.body#/employerId}
336344 */
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 > ) {
338352 if ( Object . prototype . toString . call ( value ) === '[object Object]' ) {
339353 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} )
341355 return acc
342356 } , { } )
343357 }
344358
345- if ( value . search ( / { | } / ) === - 1 ) {
359+ if ( typeof value !== 'string' ) {
360+ return value
361+ } else if ( value . search ( / { | } / ) === - 1 ) {
346362 return isRuntimeExpression ( value )
347363 ? resolveRuntimeExpression ( paramName , value , resolveData , source , args )
348364 : value
@@ -476,7 +492,7 @@ export function getResolver<TSource, TContext, TArgs>({
476492
477493 let value = argsFromLink [ paramName ]
478494
479- args [ saneParamName ] = inferLinkArguments ( paramName , value , resolveData , source , args )
495+ args [ saneParamName ] = inferLinkArguments ( { paramName, value, resolveData, source, args} )
480496 }
481497
482498 // Stored used parameters to future requests:
0 commit comments