Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
MangoMarcus opened this issue Apr 23, 2024 · 5 comments

Comments

@MangoMarcus
Copy link

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
@brandonkelly
Copy link
Member

Can you try clearing your data caches?

@MangoMarcus
Copy link
Author

Hey @brandonkelly , yep clearing the data cache seems to fix it as well, like the "graphql queries" cache.

I guess there's a cache that needs to be invalidated when moving an entry to a new parent?

@brandonkelly
Copy link
Member

Yep, thanks for checking! Just fixed this for the next v4 and v5 releases.

@MangoMarcus
Copy link
Author

Awesome, tyvm!

@brandonkelly
Copy link
Member

Craft 4.8.11 and 5.0.6 are out with that fix. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants