Skip to content

Refetch resolves queries with variables from every previous component mounts #7254

Closed
@kestutis-buivydas

Description

Intended outcome:
Refetch should resolve query only with current variable.

Actual outcome:
Multiple queries with variables from every previous component mounts are resolved.

How to reproduce the issue:
Repo: https://github.com/kestas-devbridge/react-apollo-error-template

Create component with useQuery which has skip: true and fetch-policy: 'network-only':

const { refetch } = useQuery(PERSON, {
    fetchPolicy: 'network-only',
    skip: true,
});

Then on refetch pass variable:

const onChange = () => {
    refetch({ id: '1' })
};

Dismount and mount component again and refetch with different variable value:

const onChange = () => {
    refetch({ id: '2' })
};

Result: Queries both for id '2' and '1' will be resolved.

Note: with every additional dismount and mount count of queries resolved will increase.

Versions

System:
    OS: macOS 10.15.7
Binaries:
    Node: 11.3.0
    npm: 6.10.1
Browsers:
    Chrome: 86.0.4240.111
npmPackages:
    @apollo/client: ^3.2.5 => 3.2.5 

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions