verbb / vizy

A flexible visual editor for Craft CMS
Other
44 stars 8 forks source link

Enabling Vizy breaks Craft GraphQL support #165

Closed r0skar closed 2 years ago

r0skar commented 2 years ago

Describe the bug

When installing and enabling the Vizy plugin, all Craft GQL queries return an error

{
  "errors": [
    {
      "message": "Attempt to read property \"handle\" on null"
    }
  ]
}

Steps to reproduce

  1. Install and enable Vizy
  2. Open the GraphQL playground and run a simple query

Craft CMS version

Craft Pro 4.2.0.2

Plugin version

2.0.4

Multi-site?

No

Additional context

After disabling the plugin and running a query successfully, it will keep working as long as its in cache.

engram-design commented 2 years ago

Are you able to have a look in your logs for more detail? I can't replicate this immediately, but your log files will contain the full stack trace.

You might want to delete your logs first, then try and run a GQL query - just to isolate the log file entry.

r0skar commented 2 years ago

Sure - sorry for not including them in the initial bug report.

2022-08-05 07:51:31 [web.ERROR] [yii\base\ErrorException:2] yii\base\ErrorException: Attempt to read property "handle" on null in /home/************************/vendor/verbb/vizy/src/nodes/VizyBlock.php:196
Stack trace:
#0 /home/************************/vendor/craftcms/cms/src/web/ErrorHandler.php(77): yii\base\ErrorHandler->handleError()
#1 /home/************************/vendor/verbb/vizy/src/nodes/VizyBlock.php(196): craft\web\ErrorHandler->handleError()
#2 /home/************************/vendor/verbb/vizy/src/gql/types/generators/VizyNodeGenerator.php(49): verbb\vizy\nodes\VizyBlock->getGqlTypeName()
#3 /home/************************/vendor/craftcms/cms/src/services/Gql.php(387): verbb\vizy\gql\types\generators\VizyNodeGenerator::generateTypes()
#4 /home/************************/vendor/craftcms/cms/src/services/Gql.php(501): craft\services\Gql->getSchemaDef()
#5 /home/************************/vendor/craftcms/cms/src/controllers/GraphqlController.php(177): craft\services\Gql->executeQuery()
#6 [internal function]: craft\controllers\GraphqlController->actionApi()
#7 /home/************************/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#8 /home/************************/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#9 /home/************************/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()
#10 /home/************************/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction()
#11 /home/************************/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application->runAction()
#12 /home/************************/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application->_processActionRequest()
#13 /home/************************/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest()
#14 /home/************************/web/index.php(26): yii\base\Application->run()
#15 {main} {"memory":3905432,"exception":"[object] (yii\\base\\ErrorException(code: 2): Attempt to read property \"handle\" on null at /home/************************/vendor/verbb/vizy/src/nodes/VizyBlock.php:196)"} 
2022-08-05 07:51:31 [web.INFO] [application] Request context:
$_GET = [
    'p' => 'admin/actions/graphql/api'
]
engram-design commented 2 years ago

Hmm, this seems to point to a block that's been orphaned from its field. I'll look into this.

Are you able to comment on your Vizy fields? Are you using this in Matrix/Super Table/Neo combinations for example?

r0skar commented 2 years ago

Actually, I only have one basic Vizy field (without any custom blocks - just using it as a Redactor replacement) that I added as a test. I was using it in my Globals. However, even after deleting it, the error still remains, although I am not using any Vizy field at all and just have the plugin enabled.

This query was used to get the whole Globals (before I deleted the Vizy field):

query MyQuery {
  globalSets {   
    ... on messages_GlobalSet {
      # Vizy Field
      pageNotFoundMessage
    }
    ... on seo_GlobalSet {
      seoTitle
      seoDescription
      seoImage {
        url
      }
    }
  }
}

But as I said previously, I got the same error no matter if I queried the field at all. eg. Following query also throws, allthough no Vizy field is used.

query MyQuery {
  entries(section: "page") {
    id
  }
}

Here is a list of all plugins I currently have installed:

Amazon S3   2.0.1
Colour Swatches     4.2.0.1
Control Panel CSS   2.5.0
Dashboard Begone    2.0.0
Quick Field     2.0.2
Typed link field    2.1.3-rc
Vizy    2.0.4

P.S. Its overall a fresh Craft installation with almost no content as of now.

engram-design commented 2 years ago

Fixed for the next release. To get this fix early, change your verbb/vizy requirement in composer.json to:

"require": {
  "verbb/vizy": "dev-craft-4 as 2.0.4",
  "...": "..."
}

Then run composer update.

r0skar commented 2 years ago

Thanks! It all seems to working as expected now :+1: p.s. Is there any ETA for the new release?

engram-design commented 2 years ago

Fixed in 2.0.5

denisyilmaz commented 1 year ago

White this error is fixed in Vizy v2.0.5 the version for Craft 3 is still having the same issue. The last working version here is Vizy v1.0.14. Every version after this results in the same error described above.

Any plans that the bugfix will also rolled out for Vizy v1?

engram-design commented 1 year ago

@denisyilmaz If you're able to try out the change in craft-3 just to confirm? To get this fix early, change your verbb/vizy requirement in composer.json to:

"require": {
  "verbb/vizy": "dev-craft-3 as 1.0.21",
  "...": "..."
}

Then run composer update.