leoschettini
leoschettini
WWasp-lang
Created by leoschettini on 3/27/2024 in #đŸ™‹questions
Calling queries without useQuery hook
Hmm, not sure I have an answer. Perhaps examples/sample code plus linking it to relevant pages could be a good way of doing that. The docs does mention the need to pass queryCacheKey: https://wasp-lang.dev/docs/data-model/operations/actions#advanced-usage, it's just not linked to queries. With that, perhaps restructuring the docs to have a section for what is common between both actions and queries. Although my issue was probably because I don't understand TS enough to know I could solve that casting the object to any. I could have extrapolated that from what is already in the docs.
19 replies
WWasp-lang
Created by leoschettini on 3/27/2024 in #đŸ™‹questions
Calling queries without useQuery hook
yes, indeed!
19 replies
WWasp-lang
Created by leoschettini on 3/27/2024 in #đŸ™‹questions
Calling queries without useQuery hook
Sorry for the long delay. Now I cannot reproduce the issue anymore, I removed the @ts-nocheck and it still works normally đŸ¤”
19 replies
WWasp-lang
Created by leoschettini on 3/27/2024 in #đŸ™‹questions
Calling queries without useQuery hook
I also found under server/operations/queries the code that injects the context to the query. So the context of the GitHub issue is also clear.
19 replies
WWasp-lang
Created by leoschettini on 3/27/2024 in #đŸ™‹questions
Calling queries without useQuery hook
Thank you for the fast and complete answer! The solution with cast worked without errors. Although I had to ignore typescript checks for it to compile.
// @ts-nocheck
const creatorAssistants = await getUserWritingAssistants((getUserWritingAssistants as any).queryCacheKey);
// @ts-nocheck
const creatorAssistants = await getUserWritingAssistants((getUserWritingAssistants as any).queryCacheKey);
With the type check, it would still complain about a missing second argument. And this I assume is because of the missing Query type.
19 replies