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

Cached Local API: related documents are not revalidated #86

Open
hristokoev opened this issue Jul 13, 2024 · 1 comment
Open

Cached Local API: related documents are not revalidated #86

hristokoev opened this issue Jul 13, 2024 · 1 comment

Comments

@hristokoev
Copy link

Hi,

Say I have a jobs and organizations collections, where jobs has a relationship field organization to organizations. Both of the collections are enabled in the cached local API config for revalidation and are revalidating successfully upon change.

However, when I update an organization, the nested field title of organization doesn't update, i.e. jobs.docs[0].organization.title.

const jobs = await cachedPayload.find({
  collection: 'jobs',
  depth: 1,
})

Initial API shows this:

{
  "docs": [
    {
      "id": "6692b9c62095d45df53a4c6a",
      "title": "Published Job 1",
      "organization": {
        "id": "6692ad052095d45df53a4880",
        "title": "Organization 1",
        "slug": "organization-1",
      },
     ...
     }
  ]
  ...
}

After changing:

{
  "docs": [
    {
      "id": "6692b9c62095d45df53a4c6a",
      "title": "Published Job 1",
      "organization": {
        "id": "6692ad052095d45df53a4880",
        "title": "Organization 1 Changed",
        "slug": "organization-1",
      },
     ...
     }
  ]
  ...
}

But on the frontend, the cached response still shows organization.title as "Organization 1".

I thought, okay, I actually should also revalidate the job itself, which I did, and nothing changed.

Enabling useSimpleCacheStrategy: true, in the config fixed this, but as I understand this calls revalidation after any change in the database, and I don't think that'll be very performant when there'll be thousands of documents.

Maybe I'm missing something, or maybe that's a bug. Appreciate any help, thanks!

@r1tsuu
Copy link
Owner

r1tsuu commented Aug 6, 2024

Hi @hristokoev, will try to fix it here #91 as well with updating Payload

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

No branches or pull requests

2 participants