-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
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