Apollo-angular: New subscription for each call to fetchMore

Created on 17 Oct 2017  路  7Comments  路  Source: kamilkisiela/apollo-angular

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!

Most helpful comment

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

All 7 comments

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

@kamilkisiela Did you have a chance to look at this one?

Hi @kamilkisiela Did you have some update?

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

Any new about this issue?

Does anyone want to take a look at this? I could help and answer all questions about Apollo if needed.

I'm closing in favor of this one apollographql/apollo-client#2286

Was this page helpful?
0 / 5 - 0 ratings