Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Breaking change in 3.1.5 in useLazyQuery #4040

@wild-lotus

Description

@wild-lotus

Intended outcome:

Keep my test passing when upgrading @apollo/react-hooks from 3.1.3 to 3.1.5.

Actual outcome:

A bunch of tests started failing. I traced it down to usages of useLazyQuery + useEffect on mount. It seems the first returned state used to be loading, but now it is the previous one (loading: false, data: undefined, error: undefined, I will call this "initial" state).

The breaking change seems to be in 3.1.5.

For the record, we use @apollo/react-testing MockedProvider in the tests.

How to reproduce the issue:

Reproduction CodeSandbox: https://codesandbox.io/s/react-testing-library-demo-8cdgd?file=/src/__tests__/lazy-query-first-state.js

There is a minimal test asserting the first rendered state. Change @apollo/react-hooks dependency version to 3.1.5 and check how the first rendered state changes to the "initial" state and the test starts failing.

In before "use useQuery": I am aware of it, but we cannot change that in our complex codebase for now.

Version

System:
OS: macOS Mojave 10.14.6
Binaries:
Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
Yarn: 1.22.4 - ~/Proyectos/toptal/toptal-core/staff-portal/node_modules/.bin/yarn
npm: 6.14.2 - ~/Proyectos/toptal/toptal-core/staff-portal/node_modules/.bin/npm
Browsers:
Chrome: 83.0.4103.116
Firefox: 78.0.1
Safari: 13.1.1
npmPackages:
@apollo/react-hooks: ^3.1.5 => 3.1.5
@apollo/react-testing: ^3.1.3 => 3.1.3
apollo: ^2.21.2 => 2.25.0
apollo-cache-inmemory: ^1.6.3 => 1.6.6
apollo-client: ^2.6.4 => 2.6.9
apollo-link: ^1.2.13 => 1.2.14
apollo-link-batch-http: ^1.2.13 => 1.2.14
apollo-link-context: ^1.0.19 => 1.0.19
apollo-link-error: ^1.1.12 => 1.1.12
apollo-link-http: ^1.5.16 => 1.5.16
apollo-link-rest: ^0.7.3 => 0.7.3
apollo-link-schema: ^1.2.4 => 1.2.4
apollo-link-token-refresh: ^0.2.7 => 0.2.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions