Preview
By default Codex GraphQL API provides only published content. However, there are times when you need to access unpublished content too. For example, you might need to preview how a new article will look before publishing it making it public to everybody.
The Codex GraphQL API gives you the control to choose if you want to retrieve unpublished content too, by using the preview argument, available both to single entry retrieval field and collection fields.
An example for retrieving a single unpublished recipe with a specific Id would be:
query {
recipe(
id: "meTrC06uRK"
preview=true
){
id
timeToCook
tags
image
parameters
}
}
By providing the preview argument as true, the Codex GraphQL API returns the recipe even if it was not published yet, otherwise it would return a null result.
To query multiple unpublished recipes you would need to write the following GraphQL query:
query {
recipeCollection(
preview=true
){
items {
id
timeToCook
tags
image
parameters
}
}
}
By providing the preview argument as true in collections, the Codex GraphQL API returns the list of all content (both published and unpublished). Additionaly you can use custom filtering to filter entries based on a specific entry status. For example to retrieve all recipes which were archived you would need to write the followig GraphQL query:
query {
recipeCollection(
preview=true
where { status: { eq: ARCHIVED } }
){
items {
id
timeToCook
tags
image
parameters
}
}
}