I’d love some help understanding how to work with drafts and published documents. I’m running into issues with including drafts in queries because documents that are published...

1 replies
Last updated: Jan 5, 2021
I’d love some help understanding how to work with drafts and published documents. I’m running into issues with including drafts in queries because documents that are published but also have unpublished changes return two separate items,
<_id
and
drafts.<_id>
. How can I achieve something similar to the studio’s documents list pane, where each item shows only one time whether or not it’s published and there’s an edit icon if there are changes?
Jan 5, 2021, 12:02 AM
Finally found it! For anyone else looking for this in the future, you can find the
collate
util implemented here in the source code: https://github.com/sanity-io/sanity/blob/f4b66a8695b30d387a2de97d3737252616854a54/[…]nity/desk-tool/src/panes/documentsListPane/DocumentsListPane.js
Jan 5, 2021, 2:30 AM

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?