Skip to content

[4.x]: Entry missing from descendants in GQL response after moving in structure #14846

@MangoMarcus

Description

@MangoMarcus

What happened?

Description

Entry is missing after moving it to a new parent and querying descendants for it's new parent with graphql, eg. with

query GetChildEntries($elementId: QueryArgument) {
  entry(id: [$elementId]) {
    descendants {
      title
    }
  }
}

I tried to replicate the issue with PHP queries eg. Entry::find()->descendantOf(1234)->select('title')->column() but that worked as expected, so it does seem to be isolated to graphql.

If you clear the GraphQL cache under Utilities > Caches > Invalidate Data Caches > GraphQL queries, it does then return the correct response.

This issue only happens when moving an entry under a parent, not moving it from the parent.

Steps to reproduce

  1. Set up an entry structure like this
    Screenshot 2024-04-23 at 13 44 55

  2. Query the descendents of the parent using the parent's ID

    curl -X POST \
      -H "content-type: application/json" \
      -H "authorization: Bearer TOKEN_HERE" \
      --data '{"query":"query GetChildEntries($elementId: QueryArgument) {\n  entry(id: [$elementId]) {\n    descendants {\n      title\n    }\n  }\n}","variables":{"elementId":ID_HERE},"operationName":"GetChildEntries"}' \
      DOMAIN_HERE/index.php/CP_TRIGGER_HERE/actions/graphql/api
  3. Get the expected result:

    {"data":{"entry":{"descendants":[{"title":"Beauty & Fashion"},{"title":"Leisure & Hospitality"},{"title":"Breweries & Beverages"}]}}}
  4. Move another entry under the same parent
    Screenshot 2024-04-23 at 13 49 36

  5. Query again with the same curl request

Expected behavior

You should get

{"data":{"entry":{"descendants":[{"title":"Beauty & Fashion"},{"title":"Leisure & Hospitality"},{"title":"Breweries & Beverages"},{"title":"Automotive"}]}}}

Actual behavior

You actually get the same result as before

{"data":{"entry":{"descendants":[{"title":"Beauty & Fashion"},{"title":"Leisure & Hospitality"},{"title":"Breweries & Beverages"},{"title":"Automotive"}]}}}

Craft CMS version

4.8.9

PHP version

8.2

Operating system and version

ddev version v1.22.6

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

  • Batch Actions - 1.3.1
  • Block Usage - 1.0.2
  • CKEditor - 3.8.3
  • CP Field Inspect - 1.4.4
  • Expanded Singles - 2.0.5
  • Feed Me - 5.4.0
  • Formie - 2.1.12
  • Image Resizer - 3.0.11
  • Inventory - 3.2.0
  • Logs - 4.0.0
  • Navigation - 2.0.27
  • Neo - 4.1.2
  • Phone Number - 2.2.0
  • Retour - 4.1.16
  • Scout - 4.0.0
  • SEOmatic - 4.0.48
  • Servd Assets and Helpers - 3.5.12
  • Tags - 2.0.0
  • Typed link field - 2.1.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions