fetchMore doesn't set loading to true (beta.52)
See original GitHub issueIntended outcome:
When calling fetchMore
, loading should be set to true.
Actual outcome:
It remains false and the data loads without this status ever changing, even though notifyOnNetworkStatusChange: true
has been set on the useQuery
How to reproduce the issue:
Nothing special here:
const { loading, refetch, fetchMore, error, data } = useQuery(qry, {
key: dataKey,
variables,
partialRefetch,
notifyOnNetworkStatusChange: true,
onCompleted: data => {
if (data[dataKey].totalCount) {
setTotalCount(data[dataKey].totalCount);
}
},
});
const loadMore = React.useCallback(
(options = {}, loadOnTop = false) =>
fetchMore({
updateQuery: (previousResult, { fetchMoreResult, variables }) => {
onUpdateQuery(loadOnTop);
[...]
return {
...first,
...last[dataKey],
};
},
...options,
})
.then(onLoadMore)
.catch(onLoadMoreError),
[onLoadMore, onLoadMoreError],
);
Versions Apollo client beta.52 System: OS: macOS Mojave 10.14.6 Binaries: Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node Yarn: 1.22.4 - ~/.nvm/versions/node/v12.16.1/bin/yarn npm: 6.14.5 - ~/.nvm/versions/node/v12.16.1/bin/npm Browsers: Chrome: 83.0.4103.61 Safari: 13.1.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:17
- Comments:15 (3 by maintainers)
Top Results From Across the Web
react apollo - Why would data.loading not become true during ...
I was having the same problem. Turns out you have to opt in by setting notifyOnNetworkStatusChange to true in your options:.
Read more >Can't get infinite loading with fetchmore to work - Help
I am able to fetch 4 new results of data, but the issue is, the older data is disappearing.
Read more >subscribeToMore and fetchMore for the same querry using ...
so I first have a useQuerry: const { subscribeToMore, data, loading, error, fetchMore } = useQuery( GET_CHANNEL_MESSAGES, { variables: { ...
Read more >@apollo/client | Yarn - Package Manager
Apollo Client is a fully-featured caching GraphQL client with integrations for React, Angular, and more. It allows you to easily build UI components...
Read more >graphql_flutter 4.0.0-beta.2 | Flutter Package - Pub.dev
fetchMore utility for leveraging the fetch more logic results without using ... @micimize; Fixed Mutation widget's behavior to properly set loading status.
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 Free
Top 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
@benjamn FYI, I found the reason for my problem. In our app we’ve been calling fetchMore like this:
When I removed
query: GQL_QUERY,
the loading state started to update correctly. I believe the reason is the line (condition) below:...(fetchMoreOptions.query ? fetchMoreOptions : {
(src/core/ObservableQuery.ts)Of course we were unnecessarily setting the
query
option, but since it worked in v2 I think it’s an undescribed breaking change that is worth adding to the migration guide.Happening in
rc.10