Content Stages

Basic Query from default Content Stage

The DRAFT Content Stage is currently set.

Query

{
articles {
title
}
}

Output

{
"data": {
"articles": [
{
"title": "A New World"
}
]
}
}

Querying content across all Content Stages

Setting includeCurrent to true shows the default content stage (or current if set in the headers) as well.

Query

{
articles {
documentInStages(includeCurrent: true) {
title
stage
}
}
}

Output

{
"data": {
"articles": [
{
"documentInStages": [
{
"title": "A Brave New World",
"stage": "DRAFT"
},
{
"title": "A New World",
"stage": "PUBLISHED"
}
]
}
]
}
}

Using as a Filter

Query

{
articles(stage: PUBLISHED) {
title
}
}

Output

{
"data": {
"articles": [
{
"title": "A New World"
}
]
}
}

Mutating Content Stages

Publishing to a Content Stage

mutation {
publishArticle(where: { id: "ck88r3y8w09o801058ppq9trz" }, to: PUBLISHED) {
documentInStages(includeCurrent: true) {
title
stage
}
}
}

Output

{
"data": {
"publishArticle": {
"documentInStages": [
{
"title": "A Brave New World",
"stage": "DRAFT"
},
{
"title": "A Brave New World",
"stage": "PUBLISHED"
}
]
}
}
}

Unpublishing from a Content Stage

mutation {
unpublishArticle(
where: { id: "ck88r3y8w09o801058ppq9trz" }
from: PUBLISHED
) {
documentInStages(includeCurrent: true) {
title
stage
}
}
}

Output

{
"data": {
"unpublishArticle": {
"documentInStages": [
{
"title": "A Brave New World",
"stage": "DRAFT"
}
]
}
}
}

This site uses cookies to provide you with a better user experience. For more information, refer to our Privacy Policy