Skip to content

there should be a method like queryCache.hasQueryData #486

@Shahzayb

Description

@Shahzayb

The default case with queryCache.setQueryData is "If the query does not exist, it will be created and immediately be marked as stale"

  1. What if you want to check if query exists or not

  2. In case of using queryCache.setQueryData, What to do if you don't want to create query if it does not exist

I did that to resolve 2nd issue:

const oldTimeline = queryCache.getQueryData('timeline');
if (oldTimeline) {
    queryCache.setQueryData('timeline', (groups) => {
        groups.forEach((group, i) => {
            groups[i] = group.filter((post) => post._id !== photoId);
        });
        return groups;
    });
}

As you can see, the above solution is quite cumbersome.

What if there's a method called queryCache.hasQueryData which I can use so I don't have to use
queryCache.getQueryData?

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