Daniel Favand
Solution Engineer at Sanity.io, helping clients build great content experiences.
One query to fetch the draft it it exists, and fall back to the published version of a document.
coalesce(
*[_id == 'drafts.' + $documentId][0],
*[_id == $documentId][0]
)
This query uses the coalesce GROQ function
to resolve the draft version of a document, and if it doesn't exist, fall back to the published version.
Be sure to supply a documentId
as a parameter for the query.
Solution Engineer at Sanity.io, helping clients build great content experiences.
Fetch content from the base locale regardless of whether the current document is the base or translation document
Go to Query for slugs for all available locales of this documentUsing webhooks and the Sanity API, you can merge content changes and user information
Go to Getting user information with webhooksWe can turn off validation for fields using the same logic we use to hide them
Go to Optional validation for hidden fieldsSimplify finding the right document to select when you have multiple types
Go to Filtering results for reference selectors in arrays