leoschettini
WWasp-lang
•Created by leoschettini on 3/27/2024 in #đŸ™‹questions
Calling queries without useQuery hook
Hi, I'm trying to call a query directly, from the client, without using the hook, but couldn't figure out how to do so.
I declared the query in the
main.wasp
file:
and have the function implemented in queries.ts
too:
Based on https://github.com/wasp-lang/wasp/issues/1909, I'm trying to call it like this:
That gives me this error: Property 'queryCacheKey' does not exist on type '(queryCacheKey: string[], args: any) => Promise<any>'.
Plus, based on this error, the signature of getUserWritingAssistants
will not allow me to pass the user
like that.
So, questions are: How to call the query directly, and how can I build the context to pass to the query?
For some context:
I'm implementing some post-login logic, and am setting some cookies to determine what I need to execute after login/signup. Based on these cookies, I dynamically execute different functions, some of them that need to query additional data to work properly.
I could use the useQuery
hook, but rather keep the logic abstracted from the actual component. Right now, my component is simply getting the AuthUser
and passing it to another function that does the querying.19 replies