You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
As of now, useLazyQuery cannot be prefetched during ssr, as the "forceDisabled" value passed to the underlying implementation is always set to "true".
Expected behavior useLazyQuery should accept a new parameter allowing consumers to decide if the query should be disabled out of the box.
Workaround
Call useQuery or useLazyQuery conditionally based on if the query should or should not be eager:
import{UseQueryOptions,useLazyQuery,useQuery}from'@vue/apollo-composable';importtype{DocumentParameter,OptionsParameter,UseQueryReturn,VariablesParameter,}from'@vue/apollo-composable/dist/useQuery.js';import{DocumentNode}from'graphql';typeUseLazyQueryReturn<TResult,TVariablesextendsRecord<string,unknown>>=UseQueryReturn<TResult,TVariables>&{load: (document?: DocumentNode|null,variables?: TVariables|null,options?: UseQueryOptions|null,)=>boolean;};exportfunctionuseLazyQuerySsrSafe<TResult=unknown,TVariablesextendsRecord<string,unknown>=Record<string,unknown>,>(document: DocumentParameter<TResult,TVariables>,variables?: VariablesParameter<TVariables>,options?: OptionsParameter<TResult,TVariables>,eager=false,// This line does the trick, enables prefetching for lazy queries): UseLazyQueryReturn<TResult,TVariables>{if(eager){constquery=useQuery(document,variablesasVariablesParameter<TVariables>,optionsasOptionsParameter<TResult,TVariables>,);return{
...query,// set to have a compatible apiload(){returnquery.forceDisabled.value;},};}returnuseLazyQuery(document,variables,options);}
The text was updated successfully, but these errors were encountered:
Describe the bug
As of now, useLazyQuery cannot be prefetched during ssr, as the "forceDisabled" value passed to the underlying implementation is always set to "true".
Expected behavior
useLazyQuery
should accept a new parameter allowing consumers to decide if the query should be disabled out of the box.Workaround
Call
useQuery
oruseLazyQuery
conditionally based on if the query should or should not be eager:The text was updated successfully, but these errors were encountered: