useLazyQuery loading and networkStatus when call refetch. fetchMore send two requests
See original GitHub issueHello. I try to use hook useLazyQuery to filter data with new variables. apollo client config for watch query is fetchPolicy: ‘cache-and-network’,
const [getTracks, { data, loading, error, networkStatus, called, refetch }] = useLazyQuery(TracksPageQuery);
useEffect(() => {
if (!called) {
getTracks({ variables: getQueryVariables() });
} else {
refetch(getQueryVariables());
}
}, [JSON.stringify(urlQueries)]);
When i set new variables at first time - refetch does not trigger loading as true and networkStatus always 7. But refetch with repeated variables return loading true, as i need.
I tried different fetchPolicy setting, and only with ‘cache-and-network’ and repeated variables returned loading true on refetch. Also it does not suit me to set notifyOnNetworkStatusChange, because i need to show previous result before data will update, and spinner for loading over.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5
Top Results From Across the Web
Queries - Apollo GraphQL Docs
To run a query within a React component, call useQuery and pass it a GraphQL ... Apollo Client supports two strategies for this:...
Read more >Fetch more function is undefined for useLazyQuery react ...
My goal to use it in fetch more button click. However, when I try to use it the fetchMore function is undefined. Here...
Read more >GraphQL Pagination with Apollo V3 - Part 2
The onClick handler on the “load more” button calls the fetchMore function. Then we pass in the after variable (this is basically the...
Read more >useLazyQuery with Apollo Client - YouTube
Execute GraphQL queries using the useLazyQuery hook with Apollo Client 3.Learn more about GraphQL: ...
Read more >Interfaces: ApolloQuery - Apollo Elements
networkStatus is useful if you want to display a different loading ... that fetchMore was called on this query and that the network...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same issues:
"cache-and-network"
, whenfetchMore
is called, it will make two different queries to the backend."cache-first"
policy, whenfetchMore
is called, it won’t updateloading
(but it doesn’t suffer from the first issue).I have the same issue,
The loading status change from
false
totrue
in the first call, but after that doing refech is alwaysfalse
, and checking thenetworkStatus
it’s always7
so I’m not able to get the loading correct status.