Skip to content

Cached result is not instantly returned when fetchPolicy is set to "cache-and-network" #1315

Open
@MCYouks

Description

@MCYouks

Describe the bug
When settings the query options with { fetchPolicy: "cache-and-network" }, the cached result is not instantly returned.

Instead, it waits until the data is fetched from the server to return the result.

To Reproduce
Steps to reproduce the behavior:

  1. Setup useQuery with the following options { fetchPolicy: "cache-and-network" }
  2. Setup 2 query variables: variables1 and variables2
  3. Execute the query with variables1, then variables2, then variables1 again — e.g. const { result } = useQuery(query, variable1, { fetchPolicy: "cache-and-network" })
  4. On the second time you query with variables1, the change in result won't be instantaneous. Instead, it will wait for a few seconds before updating.

Expected behavior
The cached result should be returned instantly.

Versions
vue: "^3.2.16"
@vue/apollo-composable: "^4.0.0-alpha.16"
@apollo/client: "^3.5.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