Closed artm4r closed 8 months ago
const { data } = await useAsyncQuery({ query: GetComentsForHome, clientId: 'reviews', })
this syntax works, but this solution is not quite obvious
I can confirm this, as I'm getting the same behaviour !
Was also experiencing this, looking at the typings shows the different ways to pass parameters to useAsyncQuery
type TQuery<T> = QueryOptions<OperationVariables, T>['query'];
type TVariables<T> = QueryOptions<OperationVariables, T>['variables'];
type TAsyncQuery<T> = {
query: TQuery<T>;
variables?: TVariables<T>;
key?: string;
cache?: boolean;
clientId?: string;
};
export declare function useAsyncQuery<T>(opts: TAsyncQuery<T>): AsyncData<T, Error>;
export declare function useAsyncQuery<T>(query: TQuery<T>, clientId?: string): AsyncData<T, Error>;
export declare function useAsyncQuery<T>(query: TQuery<T>, variables?: TVariables<T>, clientId?: string): AsyncData<T, Error>;
So for the following
const { data } = useAsyncQuery<MyQueryType>(
MyQueryDocument,
{
someVariable: 'abc',
},
'myApolloClient'
)
you can rewrite it as
const { data } = useAsyncQuery<MyQueryType>({
query: MyQueryDocument,
variables: {
someVariable: 'abc',
},
clientId: 'myApolloClient'
})
and it will work correctly.
Environment
Windows_NT
v16.18.1
3.0.0
1.0.0
yarn@1.22.19
vite
plugins
,modules
,apollo
@nuxtjs/tailwindcss@6.1.3
,@nuxtjs/apollo@5.0.0-alpha.4
-
Describe the bug
useAsyncQuery(GetComentsForHome, 'reviews')
uses the 'default ' client even though I specified a different client.useQuery(GetComentsForHome, { clientId: 'reviews' })
works fine.Expected behaviour
I expect module to use specified client instead of default
Reproduction
No response
Additional context
No response
Logs
No response