Webiny-js: Updating a model that is referenced doesn't show latest revision on query

Created on 10 Jul 2020  路  5Comments  路  Source: webiny/webiny-js

Adria within the community mentioned creating two models, modelA and modelB. modelB contains a reference to modelA, and if modelA is updated, modelB's reference to it shows outdated fields.

This is:

  • Bug

Expected Behavior

I believe modelB should have the current reference to modelA.

Actual Behavior

modelB will point to the first publishing of modelA.

Steps to Reproduce the Problem

  1. Create two content models within Headless CMS: I did Genre and Book
  2. Have Genre contain a reference field of Book
  3. Create a Book with some dummy data.
  4. Publish that Book
  5. Create a Genre with the reference field of that Published Book (make sure to publish Genre)
  6. Update the Book and publish a revision
  7. Head to /cms/read/environment that you are using
  8. Use the query listGenres and you will see an outdated reference to Book

Detailed Description

If you republish Genre, it will contain the updated reference to the latest publication of Book.

Possible Solution

we should make the link to the latest revision of the Book instead of the previous one.
We should update our test cases: refPublishingEntries.test.js within api-headless-cms so that it tests this updated and expected behaviour.

bug cms

All 5 comments

Yeah, we should store parent IDs when storing these references, not the exact revision ID.

Hello, just wanted to say that we've run into this exact problem and would love it if the parent ID could be stored instead of a revision ID. Thanks!

I just linked a PR that will fix this. Should go out today / tomorrow @jacqui.

I just linked a PR that will fix this. Should go out today / tomorrow @jacqui.

Amazing, that was so fast @doitadrian! Thank you.

Hey @jacqui, 4.10.0 was released yesterday.

Please check the https://github.com/webiny/webiny-js/pull/1204 (the Blog section at the bottom of the PR body) for details about the feature and further steps.

And let us know if you have any questions, thanks!

Was this page helpful?
0 / 5 - 0 ratings