craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

[4.x]: GraphQL Matrix Field Mutation error: Unregistered Type #13653

Closed robinbeatty closed 1 year ago

robinbeatty commented 1 year ago

What happened?

I'm mutating a features_feature matrix block on a products_product entry via GraphQL. Testing this locally (ddev, PHP 8.1) within the cp GraphiQL playground this works as expected. On the staging server (PHP 8.1, identical composer.json) with a freshly cloned database and all caches purged within the cp GraphiQL playground this returns the 'Something went wrong when processing the GraphQL query." error and in the logs I see the following "Tried to load an unregistered type" error:

{ "trace": [ "#0 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/webonyx/graphql-php/src/Type/Schema.php(350): craft\\gql\\TypeLoader::loadType()", "#1 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/webonyx/graphql-php/src/Type/Schema.php(326): GraphQL\\Type\\Schema->loadType()", "#2 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/webonyx/graphql-php/src/Utils/AST.php(579): GraphQL\\Type\\Schema->getType()", "#3 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/webonyx/graphql-php/src/Utils/AST.php(569): GraphQL\\Utils\\AST::typeFromAST()", "#4 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php(436): GraphQL\\Utils\\AST::typeFromAST()", "#5 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php(322): GraphQL\\Utils\\TypeInfo::typeFromAST()", "#6 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/webonyx/graphql-php/src/Language/Visitor.php(466): GraphQL\\Utils\\TypeInfo->enter()", "#7 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/webonyx/graphql-php/src/Language/Visitor.php(277): GraphQL\\Language\\Visitor::GraphQL\\Language\\{closure}()", "#8 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/webonyx/graphql-php/src/Validator/DocumentValidator.php(224): GraphQL\\Language\\Visitor::visit()", "#9 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/webonyx/graphql-php/src/Validator/DocumentValidator.php(116): GraphQL\\Validator\\DocumentValidator::visitUsingRules()", "#10 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/webonyx/graphql-php/src/GraphQL.php(153): GraphQL\\Validator\\DocumentValidator::validate()", "#11 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/webonyx/graphql-php/src/GraphQL.php(94): GraphQL\\GraphQL::promiseToExecute()", "#12 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/craftcms/cms/src/services/Gql.php(512): GraphQL\\GraphQL::executeQuery()", "#13 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/craftcms/cms/src/controllers/GraphqlController.php(185): craft\\services\\Gql->executeQuery()", "#14 [internal function]: craft\\controllers\\GraphqlController->actionApi()", "#15 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()", "#16 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/yiisoft/yii2/base/Controller.php(178): yii\\base\\InlineAction->runWithParams()", "#17 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/yiisoft/yii2/base/Module.php(552): yii\\base\\Controller->runAction()", "#18 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/craftcms/cms/src/web/Application.php(304): yii\\base\\Module->runAction()", "#19 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/craftcms/cms/src/web/Application.php(607): craft\\web\\Application->runAction()", "#20 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/craftcms/cms/src/web/Application.php(283): craft\\web\\Application->_processActionRequest()", "#21 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/yiisoft/yii2/base/Application.php(384): craft\\web\\Application->handleRequest()", "#22 /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/web/index.php(12): yii\\base\\Application->run()", "#23 {main}" ], "memory": 16018240, "exception": "[object] (craft\\errors\\GqlException(code: 0): Tried to load an unregistered type \"features_MatrixBlockContainerInput\". This can indicate both a typo in the query or an issue with the schema used. at /home/737861.cloudwaysapps.com/arydwdejjp/public_html/craft/vendor/craftcms/cms/src/gql/TypeLoader.php:39)" }

Matrix mutations had previously been working as expected in production, so I imagined that there was an issue with how an entry's fields get registered with the GraphQL service. Tried resaving the entry type to get the fields register but no effect.

My query looks like this: `mutation save_products_product_Entry($id: ID, $features_blocks: [features_MatrixBlockContainerInput], $features_sortOrder: [QueryArgument]) { save_products_product_Entry( id: $id, features:{ blocks:$features_blocks, sortOrder:$features_sortOrder } ) { id } }

with variables: { "id": "26226", "features_blocks": [], "features_sortOrder": [] }`

Can you help? Rather urgent as this is down in production after cms upgrade... though not sure at what point it stopped working.

Craft CMS version

4.5.3

PHP version

8.1

Operating system and version

No response

Database type and version

MariaDB 10.4

Image driver and version

No response

Installed plugins and versions

- "amici/craft-super-dynamic-fields": "2.0.0.5", "born05/craft-sentry": "^2.0", "carlcs/craft-uielementfields": "2.0.3", "craftcms/aws-s3": "2.0.3", "craftcms/cms": "4.5.3", "craftcms/feed-me": "5.2.0", "craftcms/mailgun": "^3.0", "craftcms/redactor": "3.0.4", "doublesecretagency/craft-cpcss": "2.6.0", "doublesecretagency/craft-cpjs": "^2.5", "ether/simplemap": "4.0.4", "jamesedmonston/graphql-authentication": "^2.5", "nystudio107/craft-vite": "4.0.6", "ostark/craft-async-queue": "^3.1", "putyourlightson/craft-campaign": "^2.8", "putyourlightson/craft-dashboard-begone": "^2.0", "ryssbowh/craft-emails": "2.1.0", "ryssbowh/craft-triggers": "2.1.4", "spicyweb/craft-quick-field": "2.0.5", "vaersaagod/matrixmate": "2.1.3", "verbb/field-manager": "3.0.7", "verbb/smith": "2.0.0", "verbb/super-table": "3.0.9", "vlucas/phpdotenv": "^5.4.0"

i-just commented 1 year ago

Hi, thanks for getting in touch! It sounds like a duplicate of https://github.com/craftcms/cms/issues/13622 - fixed for the next release.