Do I have a way to use useLazyQuery ?
My app filters some data.
I need to be able to refetch whenever the user clicks on "search" with the new filters.
I also don't need to fetch when the form is not dirty.
I tried this :
But when I use
filterProperties
in another component it doesn't filters with the right filters
.
Is it a problem with react-hook-form?
Or is it a problem with useQuery?kapa.ai•19d ago
Hi @Estelle. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the knowledge sources provided, Wasp currently uses the
useQuery
hook from react-query
for data fetching. The useQuery
hook in Wasp is a thin wrapper around the useQuery
hook from react-query
and it doesn't require you to supply the cache key as Wasp handles this for you automatically source (https://wasp-lang.dev/docs/data-model/operations/queries#the-usequery-hook-1).
However, react-query
does not provide a useLazyQuery
hook like Apollo Client does. Instead, you can control the execution of the query by using the enabled
option in the useQuery
hook. If enabled
is set to false
, the query will not run automatically, but you can manually trigger it using the refetch
function returned by useQuery
.
In your case, it seems like you're already using the enabled
option correctly. The issue might be related to how you're using filterProperties
in another component. If the filters
value has changed in the other component, you might need to pass the new filters
to the refetch
function to ensure the query uses the updated filters.
As for react-hook-form
, it's hard to say without more context, but it's possible that the issue might be related to how you're watching and updating the filters
value. You might need to ensure that the filters
value is being updated correctly when the form values change.
Please note that this is a general advice based on the provided knowledge sources and the common usage of react-query
and react-hook-form
. For a more specific solution, you might need to refer to the documentation of react-query
, react-hook-form
, and Wasp, or ask for help in their respective communities.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Estelle, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?miho•18d ago
Could you maybe share a bit more of your code? Maybe a complete example so I can test it out and see what's going on 🙂
2.7KMembers
View on DiscordWant results from more Discord servers?
More PostsWhere to see migration files?I have messed up one migration (because I had to delete my local code), and now I don't know where tFile upload size limitI'm trying to implement max file upload size to the s3 bucket. I've handled the front-end but I worrAuthis there a sample bypass to login the auth while in developmentQuick Start not working?I'm following this tutorial: https://wasp-lang.dev/docs/quick-start
After opening my terminal and rI cant see ubunbtu on my Linux sub system folderI just started with this programming stuff and i wanted to try my app with this new ai called magegpIs it possible to separate client and server wasp build?each time I update stuff on client, and want to push to netlify, I need to run wasp build, but it refly.io deployment errorI tried to deploy to fly.io, and I set DATABASE_URL, and I tested it can connect successfully with dfront end developers demand in job marketCan anyone please tell me about the demand of a beginner level front end developer in job market nowPassing Context for Dependency InjectionIs there a standard pattern for passing the context object for database interaction to functions?
WGetting Updates to the Open SaaS Template (not working?)I am following the guide in [Getting Started](https://docs.opensaas.sh/start/getting-started/), howe