I am trying to get all the pages to meet certain criteria using GraphQL
query as below. But this query returns all versions of the page. (We need this in Preview mode of the page)
How can we restrict the query to consider only the latest version of the page? (There is latestVersion
parameter for the search query tried using this in the Search query parameter. But it gives an error. Probably it is not the correct way of using this parameter).
query GetBlogs(
$after: String
$language: String!
$numberOfPages: Int
$pageName: String!
$rootFolderId: String!
$tagFilter: ItemSearchPredicateInput
) {
pageResults: search(
where: {
AND: [
{ name: "_language", operator: EQ, value: $language }
{ name: "_hasLayout", value: "true" }
{
name: "_templates"
operator: CONTAINS
value: "acd3828a-d5b4-41fa-8a1e-1030e28b0c9a"
}
$tagFilter
{ name: "_name", operator: NEQ, value: $pageName }
{ name: "_path", operator: CONTAINS, value: $rootFolderId }
]
}
orderBy: { name: "date", direction: DESC }
first: $numberOfPages
after: $after
) {
total
pageInfo {
endCursor
hasNext
}
results {
...SearchBlogs
}
}
}
fragment SearchBlogs on C__AppRoute {
id
language {
name
}
metaDescription {
jsonValue
}
file {
jsonValue
}
picture {
jsonValue
}
url {
path
}
pageTitle {
jsonValue
}
tags {
id
jsonValue
}
}
Thanks,
Shrutika