@@ -114,6 +114,22 @@ function withContextSignal(
114114 }
115115}
116116
117+ function resolvePathSegmentFromCallArg ( body : unknown ) : string | undefined {
118+ if ( typeof body !== 'object' || body === null ) return undefined
119+
120+ const entries = Object . entries ( body as Record < string , unknown > )
121+ if ( entries . length === 0 ) return undefined
122+
123+ const [ paramName , paramValue ] = entries [ 0 ]
124+
125+ // Keep dynamic placeholder when call-site intentionally passes an empty value.
126+ if ( paramValue === '' || paramValue == null ) {
127+ return `:${ paramName } `
128+ }
129+
130+ return String ( paramValue )
131+ }
132+
117133interface ProxyContext {
118134 raw : any
119135 prefix : QueryKey
@@ -288,9 +304,9 @@ function createEdenTQProxy(
288304 )
289305 } ,
290306 apply ( _ , __ , [ body ] ) {
291- if ( typeof body === 'object' && body !== null ) {
292- const paramValue = Object . values ( body ) [ 0 ] as string
293- return createEdenTQProxy ( ctx , [ ...paths , paramValue ] )
307+ const paramSegment = resolvePathSegmentFromCallArg ( body )
308+ if ( paramSegment !== undefined ) {
309+ return createEdenTQProxy ( ctx , [ ...paths , paramSegment ] )
294310 }
295311 return createEdenTQProxy ( ctx , paths )
296312 }
@@ -400,9 +416,9 @@ function createEdenTQUtilsProxy(
400416 )
401417 } ,
402418 apply ( _ , __ , [ body ] ) {
403- if ( typeof body === 'object' && body !== null ) {
404- const paramValue = Object . values ( body ) [ 0 ] as string
405- return createEdenTQUtilsProxy ( ctx , [ ...paths , paramValue ] )
419+ const paramSegment = resolvePathSegmentFromCallArg ( body )
420+ if ( paramSegment !== undefined ) {
421+ return createEdenTQUtilsProxy ( ctx , [ ...paths , paramSegment ] )
406422 }
407423 return createEdenTQUtilsProxy ( ctx , paths )
408424 }
0 commit comments