22.03.28 useLazyQuery vs useQuery
useQuery with refetch vs useLazyQuery with useEffect
const [func] = useLazyQuery(QUERY, {
oncompleted: (res) => {
// callback function
}
})
참고 링크
1. useQuery refetch
https://www.apollographql.com/docs/react/data/queries/#refetching
Queries
Fetch data with the useQuery hook
www.apollographql.com
2. useQuery params
https://www.apollographql.com/docs/react/api/react/hooks/#result
Hooks
Apollo Client react hooks API reference
www.apollographql.com
3. How do I use onComplete with useQuery?
https://github.com/trojanowski/react-apollo-hooks/issues/106
How do I use onComplete with useQuery ? · Issue #106 · trojanowski/react-apollo-hooks
Hi guys, I want to do something after each polling but couldn't find how to use onCompleted: onCompleted: (data: TData | {}) => void A callback executed once your query successfully complete...
github.com
4. Wait for useLazyQuery response
https://stackoverflow.com/questions/62122523/wait-for-uselazyquery-response
Wait for useLazyQuery response
I need to call a query when submit button is pressed and then handle the response. I need something like this: const [checkEmail] = useLazyQuery(CHECK_EMAIL) const handleSubmit = async () => {
stackoverflow.com
5. How to render useQuery both on first render and onclick?
How to render useQuery both on first render and onclick? [ReactJS, graphql]
How do I get my useQuery() to fire on both first render as well as on subsequent events (e.g. button click)? From what I've read, when React mounts a component that calls a useQuery for the first t...
stackoverflow.com
6. useQuery with onCompleted: infinite loop
https://github.com/apollographql/react-apollo/issues/4044
useQuery with onCompleted: infinite loop. · Issue #4044 · apollographql/react-apollo
Hello! I had this code before updating to v3: const { data: dataEvents, loading: loadingEvents, error: errorEvents, } = useQuery( getEventsQuery, { fetchPolicy: "network-only", onComplete...
github.com
7. how to get the data from useQuery in onSuccess callback?
react-query: how to get the data from useQuery in onSuccess callback?
I am learning react-query and I meet some problems. I want to use the data I get from fetching data by useQuery, but I get data as undefined. Here is my code: import React from "react"; i...
stackoverflow.com