verbb / super-table

Super-charge your Craft workflow using Super Table.
MIT License
316 stars 47 forks source link

craft\errors\GqlException: Tried to load an unregistered type #327

Closed MarcHartwig13 closed 2 years ago

MarcHartwig13 commented 4 years ago

Description

I'm running into an issue where graphQL doesn't return any data for random fields. The data saves in the CMS fine but graphQL acts as if it doesn't exist. The field types I'm trying to access are a text field and a preparse field. My field setup is Matrix field > Super Table in block with other fields > text field/preparse field within super table

Here is my stack trace:

2020-01-29 15:12:05 [-][-][-][error][craft\errors\GqlException] craft\errors\GqlException: Tried to load an unregistered type „landingPageContent_iconCards_BlockType”. This can indicate both a typo in the query or an issue with the schema used. in /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/craftcms/cms/src/gql/TypeLoader.php:39
Stack trace:
#0 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/webonyx/graphql-php/src/Type/Schema.php(319): craft\gql\TypeLoader::loadType('landingPageCont...')
#1 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/webonyx/graphql-php/src/Type/Schema.php(212): GraphQL\Type\Schema->loadType('landingPageCont...')
#2 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/webonyx/graphql-php/src/Utils/AST.php(504): GraphQL\Type\Schema->getType('landingPageCont...')
#3 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php(66): GraphQL\Utils\AST::typeFromAST(Object(GraphQL\Type\Schema), Object(GraphQL\Language\AST\NamedTypeNode))
#4 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/webonyx/graphql-php/src/Validator/Rules/OverlappingFieldsCanBeMerged.php(825): GraphQL\Utils\TypeInfo::typeFromAST(Object(GraphQL\Type\Schema), Object(GraphQL\Language\AST\NamedTypeNode))
#5 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/webonyx/graphql-php/src/Validator/Rules/OverlappingFieldsCanBeMerged.php(743): GraphQL\Validator\Rules\OverlappingFieldsCanBeMerged->internalCollectFieldsAndFragmentNames(Object(GraphQL\Validator\ValidationContext), Object(GraphQL\Type\Definition\UnionType), Object(GraphQL\Language\AST\SelectionSetNode), Array, Array)
#6 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/webonyx/graphql-php/src/Validator/Rules/OverlappingFieldsCanBeMerged.php(164): GraphQL\Validator\Rules\OverlappingFieldsCanBeMerged->getFieldsAndFragmentNames(Object(GraphQL\Validator\ValidationContext), Object(GraphQL\Type\Definition\UnionType), Object(GraphQL\Language\AST\SelectionSetNode))
#7 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/webonyx/graphql-php/src/Validator/Rules/OverlappingFieldsCanBeMerged.php(73): GraphQL\Validator\Rules\OverlappingFieldsCanBeMerged->findConflictsWithinSelectionSet(Object(GraphQL\Validator\ValidationContext), Object(GraphQL\Type\Definition\UnionType), Object(GraphQL\Language\AST\SelectionSetNode))
#8 [internal function]: GraphQL\Validator\Rules\OverlappingFieldsCanBeMerged->GraphQL\Validator\Rules\{closure}(Object(GraphQL\Language\AST\SelectionSetNode), 'selectionSet', Object(GraphQL\Language\AST\FieldNode), Array, Array)
#9 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/webonyx/graphql-php/src/Language/Visitor.php(372): call_user_func_array(Object(Closure), Array)
#10 [internal function]: GraphQL\Language\Visitor::GraphQL\Language\{closure}(Object(GraphQL\Language\AST\SelectionSetNode), 'selectionSet', Object(GraphQL\Language\AST\FieldNode), Array, Array)
#11 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/webonyx/graphql-php/src/Language/Visitor.php(426): call_user_func_array(Object(Closure), Array)
#12 [internal function]: GraphQL\Language\Visitor::GraphQL\Language\{closure}(Object(GraphQL\Language\AST\SelectionSetNode), 'selectionSet', Object(GraphQL\Language\AST\FieldNode), Array, Array)
#13 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/webonyx/graphql-php/src/Language/Visitor.php(251): call_user_func(Object(Closure), Object(GraphQL\Language\AST\SelectionSetNode), 'selectionSet', Object(GraphQL\Language\AST\FieldNode), Array, Array)
#14 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/webonyx/graphql-php/src/Validator/DocumentValidator.php(259): GraphQL\Language\Visitor::visit(Object(GraphQL\Language\AST\DocumentNode), Array)
#15 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/webonyx/graphql-php/src/Validator/DocumentValidator.php(96): GraphQL\Validator\DocumentValidator::visitUsingRules(Object(GraphQL\Type\Schema), Object(GraphQL\Utils\TypeInfo), Object(GraphQL\Language\AST\DocumentNode), Array)
#16 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/webonyx/graphql-php/src/GraphQL.php(140): GraphQL\Validator\DocumentValidator::validate(Object(GraphQL\Type\Schema), Object(GraphQL\Language\AST\DocumentNode), Array)
#17 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/webonyx/graphql-php/src/GraphQL.php(86): GraphQL\GraphQL::promiseToExecute(Object(GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter), Object(GraphQL\Type\Schema), 'query($site: St...', NULL, NULL, Array, NULL, NULL, Array)
#18 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/craftcms/cms/src/services/Gql.php(357): GraphQL\GraphQL::executeQuery(Object(GraphQL\Type\Schema), 'query($site: St...', NULL, NULL, Array, NULL, NULL, Array)
#19 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/craftcms/cms/src/controllers/GraphqlController.php(168): craft\services\Gql->executeQuery(Object(craft\models\GqlSchema), 'query($site: St...', Array, NULL, false)
#20 [internal function]: craft\controllers\GraphqlController->actionApi()
#21 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#22 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#23 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/craftcms/cms/src/web/Controller.php(178): yii\base\Controller->runAction('api', Array)
#24 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('api', Array)
#25 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/craftcms/cms/src/web/Application.php(290): yii\base\Module->runAction('graphql/api', Array)
#26 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('graphql/api', Array)
#27 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/craftcms/cms/src/web/Application.php(275): yii\web\Application->handleRequest(Object(craft\web\Request))
#28 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#29 /example-website/releases/0729b1f322ef71f50c40ae4ac594bb38bde09e25/web/index.php(21): yii\base\Application->run()
#30 {main}

This is the part of my graphQL call:

... on landingPageContent_headerIconCards_BlockType{
          typeHandle
          eyebrow
          header
          iconCard{
            ... on iconCard_BlockType{
              header
              text
              icon{
                ... on svgIcons_Asset{
                  title
                  url
                }
              }
            }
          }
          iconCardBorder
          colors
        }

I'm not sure if this is related or if I should open another issue for this but I also have an issue when creating fields in a super table and it thinks the handle is already being used. Once when I know I hadn't used the handle before and a couple other times when I had created a field, then decided I didn't need it and deleted it, and then realized I did need it and tried to recreate it.

My work around was to delete the entire matrix block and recreate everything. But this last time that didn't solve any issues.

Another thing that may be causing a conflict is we do have fields of the same handle in other matrix blocks within the same matrix.

Steps to reproduce

It's hard to list a definitive way to reproduce the issue because it seems to happen to random fields.

  1. Create a super table inside a matrix block
  2. Add text field
  3. Delete text field
  4. Add text field back in with same handle
  5. Attempt to pull data through graphQL

Additional info

I've updated both Craft and Super Table since running into this issue, so potentially things have changed. I can try to delete the block and recreate it again to see if it solves the issue?

engram-design commented 4 years ago

I've made some updates to GraphQL in the next release. To get the fix early, change your verbb/super-table requirement in composer.json to:

"require": {
  "verbb/super-table": "dev-craft-3#479fe94d25d00bc0b7921b338973c3dd13390532 as 2.4.1.2",
  "...": "..."
}

Then run composer update.

Let me know if there's still issues though!

MarcHartwig13 commented 4 years ago

Appreciate your quick response and turn around on this and #326!

Craft Version: 3.4.1 Super Table Verison: dev-craft-3#479fe94d25d00bc0b7921b338973c3dd13390532 as 2.4.1.2

Unfortunately updating to "verbb/super-table": "dev-craft-3#479fe94d25d00bc0b7921b338973c3dd13390532 as 2.4.1.2" hasn't resolved my issue.

Ran migrate/all and project-config/sync after updating to the dev version of Super Table. I tried:

All the fields save perfectly fine and the data remains. In graphQL Playground it shows the error Unable to query field 'randomTextfield' on type iconCard_BlockType But I have a text field with the handle header and that pulls in fine.

I can't seem to find a stack trace on this issue this time in any of the logs though. I could try recreating the entire Matrix but I'm hoping to avoid that. This might be a dumb question but could Super Table be pointing to an old/previous version of my matrix block for graphQL? And graphQL is stuck thinking I never created those fields/they don't exist? I'll be honest I don't know how the data from the DB gets connected/translated to graphQL enough to speak too well on it.

Thanks again for the help and let me know if I can provide anymore information that might help!


~*EDIT:** Just tried to add a text field to a different super table in a different matrix block and graphQL doesn't recognize the new field there either. Seems like it isn't picking up new fields created within the matrix.~

Sorry the above isn't true, I needed to refresh my graphQL Playground and it pulls the data correctly. Still cannot pull data from within the one specific super table in the specific matrix block. (sorry for all the edits just want to make sure I'm explaining things as best I can.)

My setup is Matrix > Matrix Block > Super Table > Text Field

MarcHartwig13 commented 4 years ago

Tried to pin this down further but couldn't find anything noticeable. All the fields in the project.yaml seemed fine.

My workaround was to delete the block and not try and use the same handle, something must be corrupt with that handle. Currently everything is working with a new handle. I'm wondering if this stems from me being on Super Table 2.3.3 while being on the 3.4-RC branches of Craft?

engram-design commented 2 years ago

This should be fixed in 3.0.0-beta.3