Skip to content

upsertQueryEntries does not create subscriptions and provided tags #4870

@sondreluc

Description

@sondreluc

Hi!

I have tried to utilize the upsertQueryEntries util to populate individual cache entries, similar to the getPosts/getPost example in the docs and v2.3.0 release notes.
This works fine, until I want to perform some optimistic updates on the different entries, as selectInvalidatedBy does not contain the individual entity queries.

I tested with replacing upsertQueryEntries with upsertQueryData, and this seems to work. Inspecting the difference in api state from the two utils, it looks like they both add all the queries to the api state, but upsertQueryData adds subscriptions and provided tags for all the individual entries, while upsertQueryEntries does not.

I have created a codesandbox where you can easily toggle between the to different utils.
Codesandbox: https://codesandbox.io/p/sandbox/agitated-surf-zxvyw5

So now I'm wondering if this is a bug, or intentional behavior and that I will have to resort to upsertQueryData if i want to be able to do optimistic updates on the individual cache entries.

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