Sorry, no results found for "".

Astro > Accessing draft/updated content

Accessing draft/updated content

If you have draft/published mode enabled on some of your models, you can use the X-Include-Drafts header to access records at their latest version available instead of the currently published one

Pages and layouts can utilize the includeDrafts option of the executeQuery function in their server load functions:

src/pages/index.astro
1
---
2
const query = `
3
query HomeQuery {
4
blogPost { title }
5
}
6
`;
7
8
const data = await executeQuery(query, { includeDrafts: true });
9
---
10
11
<article>
12
<h1>{data.blogPost.title}</h1>
13
</article>

The X-Include-Drafts is one of many headers you can use to shape up the behavior of the Content Delivery API. Check out the other available headers in the Content Delivery API.