revisions: ALL / LATEST does not work as expected

Created on 30 March 2023, over 1 year ago
Updated 15 May 2023, over 1 year ago

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?

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany philipp.krauss

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024