New subscription for each call to fetchMore
See original GitHub issueHello,
I have a problem with fetchMore
function of watchQuery
.
I have implemented a infinite scroll for my app, when i call to fechMore
function of my watchQuery
is created a new Subscription, i can see on “Apollo Dev Tools”.
The problem is i can’t unsubscribe of this new subscriptions because i don’t have any reference about them.
This is the watchQuery function:
this.query = this.apollo.watchQuery<{ Customers: Array<Customer> }> ({
query: gql`
query Customers ($orderBy: String, $first: Int, $skip: Int) {
Customers: allCustomers(
orderBy: $orderBy
first: $first
skip: $skip
) {
...customerListFragment
}
}
${ customerListFragment }
`,
variables: { orderBy: "firstName_ASC", first: 20, skip: 0 },
});
and with the reference of this i call to fetchMore:
this.query.fetchMore({
variables: { skip: 20 },
updateQuery: (prev, { fetchMoreResult }) => {
if (!fetchMoreResult) return prev;
return Object.assign({}, prev, {
Customers: [...prev.Customers, ...fetchMoreResult.Customers],
});
},
});
Each time when i call this function for feachMore results is created a new subscription. Is the expected behavior? How i can unsubscribe for this new subscriptions?
Thank you!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
New subscription for each call to fetchMore · Issue #376 - GitHub
Hello, I have a problem with fetchMore function of watchQuery. I have implemented a infinite scroll for my app, when i call to...
Read more >Subscriptions - Apollo GraphQL Docs
Subscriptions are useful for notifying your client in real time about changes to back-end data, such as the creation of a new object...
Read more >subscribeToMore and fetchMore for the same querry using ...
and I would like to both subscribe to it so I get all new messages ... time not since I already wrote how...
Read more >Apollo pagination tutorial: using fetchMore() - Emma Goto
The fetchMore function can be repeatedly called to get all your pages of data. But first, we'll be creating a couple of utility...
Read more >Pagination - Client (React) - Apollo GraphQL Docs
Offset-based pagination — also called numbered pages — is a very common pattern, ... In the example below, we use a fetchMore query...
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
I think it’s on the
apollo-client
side but give me some time to check it.I can confirm this leak happens. Is there a fix for this?