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.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.