Skip to content

[5.x]: GraphQL (Follow-up): GraphQL Filter relatedToEntries Fails with Nested Structure Sections #16433

@Thierry-Muehlemann

Description

@Thierry-Muehlemann

What happened?

Follow-up to #16431

Description

The GraphQL filter relatedToEntries: null fails specifically when querying nested entries within structure-type sections. While the original issue #16431 was fixed for most cases, this specific scenario with nested structure sections reveals a new error case.

Steps to reproduce

  1. create a section of type structure
  2. Have some nested entries
  3. Try this GraphQL query:

failing query:

query {
  entries {
   title
    children(relatedToEntries: null) {
      title
    }
  }
}

Expected behavior

Expected to list all results. Works if none of the entries were nested.

Actual behavior

GraphQL fails with a new error:

{
  "errors": [
    {
      "debugMessage": "Setting unknown property: craft\\elements\\db\\EntryQuery::relatedToEntries",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "trace": [
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php",
          "line": 617,
          "call": "yii\\base\\Component::__set('relatedToEntries', null)"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/elements/db/NestedElementQueryTrait.php",
          "line": 87,
          "call": "craft\\elements\\db\\ElementQuery::__set('relatedToEntries', null)"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/elements/db/EntryQuery.php",
          "line": 246,
          "call": "craft\\elements\\db\\EntryQuery::nestedTraitSet('relatedToEntries', null)"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/BaseYii.php",
          "line": 557,
          "call": "craft\\elements\\db\\EntryQuery::__set('relatedToEntries', null)"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/services/Elements.php",
          "line": 3257,
          "call": "yii\\BaseYii::configure(instance of craft\\elements\\db\\EntryQuery, array(1))"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/services/Elements.php",
          "line": 3178,
          "call": "craft\\services\\Elements::_eagerLoadElementsInternal('craft\\elements\\Entry', array(1), array(1))"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php",
          "line": 1808,
          "call": "craft\\services\\Elements::eagerLoadElements('craft\\elements\\Entry', array(45), array(1))"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/elements/db/EntryQuery.php",
          "line": 947,
          "call": "craft\\elements\\db\\ElementQuery::afterPopulate(array(45))"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php",
          "line": 1779,
          "call": "craft\\elements\\db\\EntryQuery::afterPopulate(array(45))"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/db/Query.php",
          "line": 251,
          "call": "craft\\elements\\db\\ElementQuery::populate(array(45))"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/db/Query.php",
          "line": 292,
          "call": "yii\\db\\Query::all(null)"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php",
          "line": 1851,
          "call": "craft\\db\\Query::all(null)"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/gql/base/ElementResolver.php",
          "line": 51,
          "call": "craft\\elements\\db\\ElementQuery::all()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 623,
          "call": "craft\\gql\\base\\ElementResolver::resolve(null, array(0), array(2), instance of GraphQL\\Type\\Definition\\ResolveInfo)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 549,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveFieldValueOrError(instance of GraphQL\\Type\\Definition\\FieldDefinition, instance of GraphQL\\Language\\AST\\FieldNode, 'craft\\gql\\resolvers\\elements\\Entry::resolve', null, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1195,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: Query, null, instance of ArrayObject(1), array(1))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 264,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: Query, null, array(0), instance of ArrayObject(1))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 215,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeOperation(instance of GraphQL\\Language\\AST\\OperationDefinitionNode, null)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/Executor.php",
          "line": 156,
          "call": "GraphQL\\Executor\\ReferenceExecutor::doExecute()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 161,
          "call": "GraphQL\\Executor\\Executor::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of GraphQL\\Type\\Schema, instance of GraphQL\\Language\\AST\\DocumentNode, null, array(2), null, null, null)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 93,
          "call": "GraphQL\\GraphQL::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of GraphQL\\Type\\Schema, '# Welcome to GraphiQL\n#\n# GraphiQL is an in-browser tool for writing, validating, and\n# testing GraphQL queries.\n#\n# Type queries into this side of the screen, and you will see intelligent\n# typeaheads aware of the current GraphQL type schema and live syntax and\n# validation errors highlighted within the text.\n#\n# GraphQL queries typically start with a \"{\" character. Lines that start\n# with a # are ignored.\n#\n# An example GraphQL query might look like:\n#\n#     {\n#       field(arg: \"value\") {\n#         subField\n#       }\n#     }\n#\n# Keyboard shortcuts:\n#\n#  Prettify Query:  Shift-Ctrl-P (or press the prettify button above)\n#\n#     Merge Query:  Shift-Ctrl-M (or press the merge button above)\n#\n#       Run Query:  Ctrl-Enter (or press the play button above)\n#\n#   Auto Complete:  Ctrl-Space (or just start typing)\n#\n\nquery {\n  entries {\n   title\n    children(relatedToEntries: null) {\n      title\n    }\n  }\n}\n', null, array(2), null, null, null, array(26))"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/services/Gql.php",
          "line": 526,
          "call": "GraphQL\\GraphQL::executeQuery(instance of GraphQL\\Type\\Schema, '# Welcome to GraphiQL\n#\n# GraphiQL is an in-browser tool for writing, validating, and\n# testing GraphQL queries.\n#\n# Type queries into this side of the screen, and you will see intelligent\n# typeaheads aware of the current GraphQL type schema and live syntax and\n# validation errors highlighted within the text.\n#\n# GraphQL queries typically start with a \"{\" character. Lines that start\n# with a # are ignored.\n#\n# An example GraphQL query might look like:\n#\n#     {\n#       field(arg: \"value\") {\n#         subField\n#       }\n#     }\n#\n# Keyboard shortcuts:\n#\n#  Prettify Query:  Shift-Ctrl-P (or press the prettify button above)\n#\n#     Merge Query:  Shift-Ctrl-M (or press the merge button above)\n#\n#       Run Query:  Ctrl-Enter (or press the play button above)\n#\n#   Auto Complete:  Ctrl-Space (or just start typing)\n#\n\nquery {\n  entries {\n   title\n    children(relatedToEntries: null) {\n      title\n    }\n  }\n}\n', null, array(2), null, null, null, array(26))"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/controllers/GraphqlController.php",
          "line": 195,
          "call": "craft\\services\\Gql::executeQuery(instance of craft\\models\\GqlSchema, '# Welcome to GraphiQL\n#\n# GraphiQL is an in-browser tool for writing, validating, and\n# testing GraphQL queries.\n#\n# Type queries into this side of the screen, and you will see intelligent\n# typeaheads aware of the current GraphQL type schema and live syntax and\n# validation errors highlighted within the text.\n#\n# GraphQL queries typically start with a \"{\" character. Lines that start\n# with a # are ignored.\n#\n# An example GraphQL query might look like:\n#\n#     {\n#       field(arg: \"value\") {\n#         subField\n#       }\n#     }\n#\n# Keyboard shortcuts:\n#\n#  Prettify Query:  Shift-Ctrl-P (or press the prettify button above)\n#\n#     Merge Query:  Shift-Ctrl-M (or press the merge button above)\n#\n#       Run Query:  Ctrl-Enter (or press the play button above)\n#\n#   Auto Complete:  Ctrl-Space (or just start typing)\n#\n\nquery {\n  entries {\n   title\n    children(relatedToEntries: null) {\n      title\n    }\n  }\n}\n', null, null, true)"
        },
        {
          "call": "craft\\controllers\\GraphqlController::actionApi()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/InlineAction.php",
          "line": 57,
          "function": "call_user_func_array(array(2), array(0))"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/Controller.php",
          "line": 178,
          "call": "yii\\base\\InlineAction::runWithParams(array(1))"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/Module.php",
          "line": 552,
          "call": "yii\\base\\Controller::runAction('api', array(1))"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/web/Application.php",
          "line": 350,
          "call": "yii\\base\\Module::runAction('graphql/api', array(1))"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/web/Application.php",
          "line": 649,
          "call": "craft\\web\\Application::runAction('graphql/api', array(1))"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/web/Application.php",
          "line": 312,
          "call": "craft\\web\\Application::_processActionRequest(instance of craft\\web\\Request)"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/Application.php",
          "line": 384,
          "call": "craft\\web\\Application::handleRequest(instance of craft\\web\\Request)"
        },
        {
          "file": "/var/www/html/web/index.php",
          "line": 12,
          "call": "yii\\base\\Application::run()"
        }
      ]
    }
  ],
  "data": {
    "entries": null
  }
}

Craft CMS version

5.5.10

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions