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.

RefetchQueries not executed using BatchHttpLink with Apollo Client 3.6.x

See original GitHub issue

Hi Folks 👋,

We’ve run into an issue where refetch queries are no longer executed when upgrading to react 3.6.x.

It seems like this is caused by combining BatchHttpLink with Apollo Client 3.6.x. If we configure the BatchHttpLink with batchMax: 1 the issue goes away.

Please note that this could be similar to https://github.com/apollographql/apollo-client/issues/9690 but I wasn’t sure.

Thanks for all the hard work on Apollo Client 🙏

Intended outcome: Refetch queries get executed.

Actual outcome: Refetch queries are not executed

How to reproduce the issue: I was able to reproduce this issue in a test case using msw.

This is regular CRA project so running npm install and npm test should do the trick.

I have two branches, one with passing tests and one with failing tests where the client is upgraded to 3.6.x:

Passing test using Apollo Client 3.5.10 => https://github.com/skrivle/apollo-refetch-repro/tree/master Failing test using Apollo Client 3.6.x => https://github.com/skrivle/apollo-refetch-repro/tree/apollo-3.6.x (passes with batchMax set to 1)

Versions

This started happening as of version 3.6.0

System:
    OS: macOS 11.6.5
  Binaries:
    Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.2/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
  Browsers:
    Chrome: 101.0.4951.64
    Firefox: 100.0.2
    Safari: 15.5
  npmPackages:
    @apollo/client: 3.6.0 => 3.6.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:9
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
natterstefancommented, Jun 1, 2022

I can confirm that this happens for us as well as soon as we update to 3.6.x also with the BatchHttpLink enabled.

2reactions
benjamncommented, Jun 10, 2022

This should be fixed if you run npm i @apollo/client@latest to get version 3.6.7 (or later). 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refetching queries in Apollo Client - Apollo GraphQL Docs
To selectively refetch queries outside of a mutation, you instead use the refetchQueries method of ApolloClient , which is documented here.
Read more >
@apollo/client | Yarn - Package Manager
Apollo Client is a fully-featured caching GraphQL client with integrations for ... It allows you to easily build UI components that fetch data...
Read more >
apollo-cache-inmemory - Awesome JS
A fully-featured, production ready caching GraphQL client for every UI ... could not be changed while a mutation is executing. by @charle692 in...
Read more >
https://raw.githubusercontent.com/bendenoz/apollo-...
Apollo Client 3.6.4 (2022-05-16) ### Bug Fixes - Guarantee `Concast` cleanup ... Fix the promise returned from the `useLazyQuery()` execution function not ......
Read more >
Issue with refetchQueries in the Apollo Client useMutation hook
I'm running into the following error while trying to define refetchQueries in my useMutation hook. Type 'DocumentNode' is not assignable to ...
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