question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New subscription for each call to fetchMore

See original GitHub issue

Hello,

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:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
kamilkisielacommented, Oct 17, 2017

I think it’s on the apollo-client side but give me some time to check it.

2reactions
raysuelzercommented, Mar 15, 2018

I can confirm this leak happens. Is there a fix for this?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found