Problem/Motivation
We are relying on an editorial workflow that lets content creators create preview revisions of their content. We need to be able to query those unpublished revisions using graphql.
For testing, I am using the following query:
{
entityQuery(
entityType: NODE
filter: {
conjunction: AND,
conditions: [
{field: "type", value: [βnewsβ]},
{field: "field_path", value: [β/some-path]}
]}
revisions: LATEST
limit: 1000
) {
total
items {
id
__typename
... on NodeNews {
status
revisionUid {
uid
id
}
vid
title
}
}
}
}
I expect to see the latest revision of my content, no matter if it is published or not. I also experimented with revisions: ALL, but this also does not help.
Looking at the code, I found that EntityQuery.php does a String comparison like this:
if ($mode === 'all') {
// Mark the query as such and sort by the revision id too.
$query->allRevisions();
$query->addTag('revisions');
}
elseif ($mode === 'latest') {
// Mark the query to only include latest revision and sort by revision id.
$query->latestRevision();
$query->addTag('revisions');
}
If I change this code to use 'ALL' and 'LATEST', I get different behavior (found this by printing the value of $mode, which is spelled uppercase for me).
I now get different behavior when using revisions: ALL: I get as many results as I have revisions. For example, I have 18 revisions of my particular news. The graphql response contains 18 times the latest published revision.
Am I doing something wrong to get $mode in uppercase?