Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache inconsistency with @defer and refetch #12250

Open
timofarei opened this issue Jan 3, 2025 · 1 comment · May be fixed by #11374
Open

Cache inconsistency with @defer and refetch #12250

timofarei opened this issue Jan 3, 2025 · 1 comment · May be fixed by #11374
Labels

Comments

@timofarei
Copy link

Issue Description

Description

When using @defer directive with Apollo Client, the cache becomes inconsistent after deleting an item and refetching. While the server returns the correct data after deletion and refetch, the UI renders duplicate entries of the remaining items.

Example query demonstrating @defer usage:

query Books {
  books {
    id
    title
    ... @defer {
      deferredInfo {
        id
        title
      }
    }
  }
}

Expected Behavior

(Refers to screenshots in Reproduction steps)
After deletion and refetch, UI should display only the remaining items matching the server response.

Actual Behavior

UI displays duplicate entries of remaining items, despite server returning correct data.

Additional Context

  • Issue occurs specifically when using @defer directive
  • Standard queries without deferred fields work correctly
  • Manual cache updates via cache.modify() resolve the issue

Link to Reproduction

https://github.com/timofarei/apollo-gql-incremental-delivery-refetch-bug

Reproduction Steps

  1. Clone repository: [link to repo]
  2. Run the app and note the list of two books:
Screenshot 2025-01-03 at 15 20 44
  1. Delete the first book using the delete button
  2. Observe that the remaining book appears twice in the list
Screenshot 2025-01-03 at 15 20 55

@apollo/client version

3.12.4

@phryneas
Copy link
Member

phryneas commented Jan 6, 2025

Hi @timofarei, thank you for the report.

I believe this is a variant of #11374.

I'll leave this open for now, but once we get that fixed, we need to re-check this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants