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

[5.x]: Issue with nested matrix field query #15708

Open
yalamber opened this issue Sep 10, 2024 · 3 comments
Open

[5.x]: Issue with nested matrix field query #15708

yalamber opened this issue Sep 10, 2024 · 3 comments

Comments

@yalamber
Copy link

What happened?

Description

In below query we have easyBuy field as Matrix and inside it we have other fields entry which work fine but when we add buttons field which is another matrix field which was migrated from super table to matrix we receive error.
in explorer we have following
Uploading Screenshot 2024-09-10 at 17.16.41.png…

query easyBuy {
  globalSet(handle: "easyBuy") {
    ... on easyBuy_GlobalSet {
      slug
      easyBuy {
        __typename
        ... on easyBuy_Entry {
          introBlurb
          __typename
          buttons {
            __typename
          }
        }
      }
    }
  }
}

Error returned

"errors": [
    {
      "debugMessage": "Runtime Object type \"buttons6Block_Entry\" is not a possible type for \"buttons_MatrixField\".",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "trace": [
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 974,
          "call": "GraphQL\\Executor\\ReferenceExecutor::ensureValidRuntimeType('buttons6Block_Entry', GraphQLType: buttons_MatrixField, instance of GraphQL\\Type\\Definition\\ResolveInfo, instance of craft\\elements\\Entry)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 789,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeAbstractValue(GraphQLType: buttons_MatrixField, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(5), instance of craft\\elements\\Entry)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 654,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: buttons_MatrixField, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(5), instance of craft\\elements\\Entry)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 887,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValueCatchingError(GraphQLType: buttons_MatrixField, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(5), instance of craft\\elements\\Entry)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 761,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeListValue(GraphQLType: buttons_MatrixField, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(4), instance of craft\\elements\\ElementCollection(1))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 740,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: buttons_MatrixField, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(4), instance of craft\\elements\\ElementCollection(1))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 654,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: buttons_MatrixField, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(4), instance of craft\\elements\\ElementCollection(1))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 556,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValueCatchingError(GraphQLType: buttons_MatrixField, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(4), instance of craft\\elements\\ElementCollection(1))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1195,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: easyBuy_Entry, instance of craft\\elements\\Entry, instance of ArrayObject(1), array(4))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1145,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: easyBuy_Entry, instance of craft\\elements\\Entry, array(3), instance of ArrayObject(3))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1105,
          "call": "GraphQL\\Executor\\ReferenceExecutor::collectAndExecuteSubfields(GraphQLType: easyBuy_Entry, instance of ArrayObject(1), array(3), instance of craft\\elements\\Entry)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 973,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeObjectValue(GraphQLType: easyBuy_Entry, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(3), instance of craft\\elements\\Entry)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 789,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeAbstractValue(GraphQLType: easyBuy_MatrixField, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(3), instance of craft\\elements\\Entry)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 654,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: easyBuy_MatrixField, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(3), instance of craft\\elements\\Entry)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 887,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValueCatchingError(GraphQLType: easyBuy_MatrixField, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(3), instance of craft\\elements\\Entry)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 761,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeListValue(GraphQLType: easyBuy_MatrixField, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(2), instance of craft\\elements\\ElementCollection(1))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 740,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: easyBuy_MatrixField, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(2), instance of craft\\elements\\ElementCollection(1))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 654,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: easyBuy_MatrixField, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(2), instance of craft\\elements\\ElementCollection(1))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 556,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValueCatchingError(GraphQLType: easyBuy_MatrixField, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(2), instance of craft\\elements\\ElementCollection(1))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1195,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: easyBuy_GlobalSet, instance of craft\\elements\\GlobalSet, instance of ArrayObject(1), array(2))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1145,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: easyBuy_GlobalSet, instance of craft\\elements\\GlobalSet, array(1), instance of ArrayObject(2))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1105,
          "call": "GraphQL\\Executor\\ReferenceExecutor::collectAndExecuteSubfields(GraphQLType: easyBuy_GlobalSet, instance of ArrayObject(1), array(1), instance of craft\\elements\\GlobalSet)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 973,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeObjectValue(GraphQLType: easyBuy_GlobalSet, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of craft\\elements\\GlobalSet)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 789,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeAbstractValue(GraphQLType: GlobalSetInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of craft\\elements\\GlobalSet)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 654,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: GlobalSetInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of craft\\elements\\GlobalSet)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 556,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValueCatchingError(GraphQLType: GlobalSetInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of craft\\elements\\GlobalSet)"
        },
        {
          "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, 'easyBuy', 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, 'query easyBuy {\n  globalSet(handle: \"easyBuy\") {\n    ... on easyBuy_GlobalSet {\n      slug\n      easyBuy {\n        __typename\n        ... on easyBuy_Entry {\n          introBlurb\n          __typename\n          buttons {\n            __typename\n          }\n        }\n      }\n    }\n  }\n}', null, array(2), null, 'easyBuy', 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, 'query easyBuy {\n  globalSet(handle: \"easyBuy\") {\n    ... on easyBuy_GlobalSet {\n      slug\n      easyBuy {\n        __typename\n        ... on easyBuy_Entry {\n          introBlurb\n          __typename\n          buttons {\n            __typename\n          }\n        }\n      }\n    }\n  }\n}', null, array(2), null, 'easyBuy', 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, 'query easyBuy {\n  globalSet(handle: \"easyBuy\") {\n    ... on easyBuy_GlobalSet {\n      slug\n      easyBuy {\n        __typename\n        ... on easyBuy_Entry {\n          introBlurb\n          __typename\n          buttons {\n            __typename\n          }\n        }\n      }\n    }\n  }\n}', null, 'easyBuy', 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": 26,
          "call": "yii\\base\\Application::run()"
        }
      ]
    }
  ],

Craft CMS version

5.4.2

PHP version

8.2

Operating system and version

linux

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@yalamber yalamber added the bug label Sep 10, 2024
@i-just
Copy link
Contributor

i-just commented Sep 10, 2024

Hi, thanks for getting in touch!

Let me check if I understand your setup correctly:

  • you have a global set with a handle of easyBuy
  • in the global set’s field layout, you have a matrix field with a handle of easyBuy
  • that matrix field has an entry type with a handle of easyBuy with introBlurb field and buttons matrix fields
  • the buttons matrix field has an entry type with a handle of buttons6Block
    Is that correct?

Also, could you please upload the screenshot again - the one from the issue description doesn’t work.

@yalamber
Copy link
Author

What I noticed was during migration of super table to matrix there was multiple fields created for buttons that was used across different matrix fields and some of those fields seem to have same handle and that's causing the issue
Screenshot 2024-09-10 at 21 02 14

@i-just
Copy link
Contributor

i-just commented Sep 11, 2024

I’m not able to reproduce the issue you’re seeing. Would you mind sending your composer.json, composer.lock, and database export to support@craftcms.com so we can reproduce and dig deeper?

The multiple fields being created is the intended behaviour during Craft 4 to Craft 5 migration. You can find more information about that here: https://craftcms.com/docs/5.x/upgrade.html#matrix-fields.

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