craftql icon indicating copy to clipboard operation
craftql copied to clipboard

"Trying to get property 'handle' of non-object" when adding a Category Group

Open Hyra opened this issue 6 years ago • 2 comments

For some reason all is working fine until I add a Category Group. From that moment on all GraphQL queries (and graphiql) give the error:

"Trying to get property 'handle' of non-object"

When i run a craftql command through the command line I get a little bit more info:


in /Users/hyra/Projects/craft-repro/vendor/markhuot/craftql/src/Types/Category.php:22

Stack trace:
#0 /Users/hyra/Projects/craft-repro/vendor/markhuot/craftql/src/Types/Category.php(22): yii\base\ErrorHandler->handleError(8, 'Trying to get p...', '/Users/hyra/Pro...', 22, Array)
#1 /Users/hyra/Projects/craft-repro/vendor/markhuot/craftql/src/Builders/Schema.php(253): markhuot\CraftQL\Types\Category->getName()
#2 /Users/hyra/Projects/craft-repro/vendor/markhuot/craftql/src/Builders/HasTypeAttribute.php(49): markhuot\CraftQL\Builders\Schema->getRawGraphQLObject()
#3 /Users/hyra/Projects/craft-repro/vendor/markhuot/craftql/src/Builders/Field.php(54): markhuot\CraftQL\Builders\Field->getTypeConfig()
#4 /Users/hyra/Projects/craft-repro/vendor/markhuot/craftql/src/Builders/Schema.php(226): markhuot\CraftQL\Builders\Field->getConfig()
#5 /Users/hyra/Projects/craft-repro/vendor/markhuot/craftql/src/Builders/Schema.php(236): markhuot\CraftQL\Builders\Schema->getFieldConfig()
#6 /Users/hyra/Projects/craft-repro/vendor/webonyx/graphql-php/src/Type/Definition/FieldDefinition.php(97): markhuot\CraftQL\Builders\Schema->markhuot\CraftQL\Builders\{closure}()
#7 /Users/hyra/Projects/craft-repro/vendor/webonyx/graphql-php/src/Type/Definition/ObjectType.php(127): GraphQL\Type\Definition\FieldDefinition::defineFieldMap(Object(GraphQL\Type\Definition\ObjectType), Object(Closure))
#8 /Users/hyra/Projects/craft-repro/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php(125): GraphQL\Type\Definition\ObjectType->getFields()
#9 /Users/hyra/Projects/craft-repro/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php(134): GraphQL\Utils\TypeInfo::extractTypes(Object(GraphQL\Type\Definition\ObjectType), Array)
#10 /Users/hyra/Projects/craft-repro/vendor/webonyx/graphql-php/src/Type/Schema.php(223): GraphQL\Utils\TypeInfo::extractTypes(Object(GraphQL\Type\Definition\ObjectType), Array)
#11 /Users/hyra/Projects/craft-repro/vendor/webonyx/graphql-php/src/Type/Schema.php(195): GraphQL\Type\Schema->collectAllTypes()
#12 /Users/hyra/Projects/craft-repro/vendor/webonyx/graphql-php/src/Type/Schema.php(137): GraphQL\Type\Schema->getTypeMap()
#13 /Users/hyra/Projects/craft-repro/vendor/markhuot/craftql/src/Services/GraphQLService.php(123): GraphQL\Type\Schema->__construct(Object(GraphQL\Type\SchemaConfig))
#14 /Users/hyra/Projects/craft-repro/vendor/markhuot/craftql/src/Console/ToolsController.php(550): markhuot\CraftQL\Services\GraphQLService->getSchema(Object(markhuot\CraftQL\Models\Token))
#15 [internal function]: markhuot\CraftQL\Console\ToolsController->actionFetchFragmentTypes()
#16 /Users/hyra/Projects/craft-repro/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#17 /Users/hyra/Projects/craft-repro/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#18 /Users/hyra/Projects/craft-repro/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('fetch-fragment-...', Array)
#19 /Users/hyra/Projects/craft-repro/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('fetch-fragment-...', Array)
#20 /Users/hyra/Projects/craft-repro/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('craftql/tools/f...', Array)
#21 /Users/hyra/Projects/craft-repro/vendor/craftcms/cms/src/console/Application.php(93): yii\console\Application->runAction('craftql/tools/f...', Array)
#22 /Users/hyra/Projects/craft-repro/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('craftql/tools/f...', Array)
#23 /Users/hyra/Projects/craft-repro/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#24 /Users/hyra/Projects/craft-repro/craft(22): yii\base\Application->run()
#25 {main}```

If i hardcode if/elses around the checks in `boot()` and `getName()` things work again, but obviously that doesnt seem the correct way to do this.

Any suggestions or ideas are more than welcome!

Hyra avatar May 09 '19 06:05 Hyra

maybe related to https://github.com/markhuot/craftql/issues/254 ?

juliansthl avatar May 13 '19 11:05 juliansthl

Running ./craft gc/run is a workaround that seems to fix this issue.

simeon-smith avatar Sep 16 '19 19:09 simeon-smith