@@ -186,7 +186,7 @@ export abstract class FetcherRenderer {
186186 hasRequiredVariables,
187187 operationVariablesTypes,
188188 } : GenerateConfig ) : string {
189- return `variables${ hasRequiredVariables ? '' : '?' } : ${ operationVariablesTypes } ` ;
189+ return `variables: ${ operationVariablesTypes } ${ hasRequiredVariables ? '' : ' = {}' } ` ;
190190 }
191191
192192 private generateQueryOptionsSignature (
@@ -203,9 +203,7 @@ export abstract class FetcherRenderer {
203203
204204 private generateInfiniteQueryVariablesSignature ( config : GenerateConfig ) : string {
205205 if ( this . visitor . config . reactQueryVersion <= 4 ) {
206- return `variables${ config . hasRequiredVariables ? '' : '?' } : ${
207- config . operationVariablesTypes
208- } `;
206+ return `variables: ${ config . operationVariablesTypes } ${ config . hasRequiredVariables ? '' : ' = {}' } ` ;
209207 }
210208 return `variables: ${ config . operationVariablesTypes } ` ;
211209 }
@@ -224,9 +222,7 @@ export abstract class FetcherRenderer {
224222
225223 public generateInfiniteQueryKey ( config : GenerateConfig , isSuspense : boolean ) : string {
226224 const identifier = isSuspense ? 'infiniteSuspense' : 'infinite' ;
227- if ( config . hasRequiredVariables )
228- return `['${ config . node . name . value } .${ identifier } ', variables]` ;
229- return `variables === undefined ? ['${ config . node . name . value } .${ identifier } ', {}] : ['${ config . node . name . value } .${ identifier } ', variables]` ;
225+ return `['${ config . node . name . value } .${ identifier } ', variables]` ;
230226 }
231227
232228 public generateInfiniteQueryOutput ( config : GenerateConfig , isSuspense = false ) {
@@ -244,8 +240,7 @@ export abstract class FetcherRenderer {
244240
245241 public generateQueryKey ( config : GenerateConfig , isSuspense : boolean ) : string {
246242 const identifier = isSuspense ? `${ config . node . name . value } Suspense` : config . node . name . value ;
247- if ( config . hasRequiredVariables ) return `['${ identifier } ', variables]` ;
248- return `variables === undefined ? ['${ identifier } ', {}] : ['${ identifier } ', variables]` ;
243+ return `['${ identifier } ', variables]` ;
249244 }
250245
251246 public generateQueryOutput ( config : GenerateConfig , isSuspense = false ) {
0 commit comments