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

Unpublishing a document should set all references to weak #7691

Open
mariusGundersen opened this issue Oct 29, 2024 · 1 comment
Open

Unpublishing a document should set all references to weak #7691

mariusGundersen opened this issue Oct 29, 2024 · 1 comment
Labels

Comments

@mariusGundersen
Copy link

mariusGundersen commented Oct 29, 2024

Is your feature request related to a problem? Please describe.
If you have an unpublished document it can reference another unpublished document. But if you have two unpublished documents where one references the other, then it's impossible to unpublish both of them, because the reference expects the referenced document to be published.

Describe the solution you'd like
When unpublishing a document all the references in it should be altered to be weak with strengthenOnPublish. For example given the following document:

{
  _id: '1',
  _type: 'doc',
  link: {
    _ref: '2',
    _type: 'reference'
  }
}

When unpublishing it should convert this to

{
  _id: '1',
  _type: 'doc',
  link: {
    _ref: '2',
    _type: 'reference',
    _weak: true,
    _strengthenOnPublish: {
      type: 'doc'
    }
  }
}

This way when the document is published again it will return the reference to the way it was before the document was unpublished.

Describe alternatives you've considered
The alternative in Sanity Studio is to temporarily remove the reference in order to unpublish the target, then recreate the reference again. This is a manuall process that is prone to errors. Outside of studio it can be done with the mutation api, but it still needs to be done with a script every time a document is going to be unpublished.

Copy link
Member

Hi mariusGundersen thank you for reporting and all the details added.

We can reproduce it internally and have flagged this as a feature request. We'll keep this issue updated with any progress

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

No branches or pull requests

2 participants