Skip to content

refetchQueries refetches queries with skipToken when provided by name #12996

@jerelmiller

Description

@jerelmiller

Issue Description

#12993 fixed an issue where a refetch without variables would occur on queries that were provided to refetchQueries: ['QueryName'] if that query had been run, then skipped with skipToken. This fixed a major issue with the suspense hooks where multiple ObservableQuery instances were created due to the switch to skipToken.

This however only solves part of the problem. We'd like to make sure queries that start with skipToken (and likely skip: true) aren't refetched until that query has been run the first time. This would prevent situations where refetchQueries might send an invalid query to the server since that query might not yet have provided any required variables. We should be able to accomplish this by waiting to subscribe to the ObservableQuery until skipToken is no longer used for the first time. ObservableQuery instances that aren't subscribed aren't registered with QueryManager, so it wouldn't be included in refetchQueries.

Link to Reproduction

n/na

Reproduction Steps

Reproduce by creating a test that uses useQuery(query, skipToken) and calling refetchQueries with that query name/document.

@apollo/client version

4.0.8

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