craftql
craftql copied to clipboard
Trying mutation on 2.0.0 beta gives "Trying to get property 'section' of non-object" error
CraftQL: ~2@dev Craft: 3.1.18
I'm attempting a pretty straightforward mutation query:
mutation newTownNews($title: String!, $townId: [Int]) {
upsertTownNews(title: $title, town: $townId) {
id
url
}
}
And I get the following error:
{
"error": "Trying to get property 'section' of non-object"
}
The same mutation works fine in 1.3.1
Error message from storage/logs/web.log
:
2019-03-30 20:01:58 [-][1][-][error][yii\base\ErrorException:8] yii\base\ErrorException: Trying to get property 'section' of non-object in /Users/steven/Code/destination-small-town/vendor/markhuot/craftql/src/FieldBehaviors/EntryMutationArguments.php:57
Stack trace:
#0 /Users/steven/Code/destination-small-town/vendor/craftcms/cms/src/web/ErrorHandler.php(81): yii\base\ErrorHandler->handleError(8, 'Trying to get p...', '/Users/steven/C...', 57)
#1 /Users/steven/Code/destination-small-town/vendor/markhuot/craftql/src/FieldBehaviors/EntryMutationArguments.php(57): craft\web\ErrorHandler->handleError(8, 'Trying to get p...', '/Users/steven/C...', 57, Array)
#2 /Users/steven/Code/destination-small-town/vendor/webonyx/graphql-php/src/Executor/Executor.php(750): markhuot\CraftQL\FieldBehaviors\EntryMutationArguments->markhuot\CraftQL\FieldBehaviors\{closure}(NULL, Array, NULL, Object(GraphQL\Type\Definition\ResolveInfo))
#3 /Users/steven/Code/destination-small-town/vendor/webonyx/graphql-php/src/Executor/Executor.php(713): GraphQL\Executor\Executor->resolveOrError(Object(GraphQL\Type\Definition\FieldDefinition), Object(GraphQL\Language\AST\FieldNode), Object(Closure), NULL, NULL, Object(GraphQL\Type\Definition\ResolveInfo))
#4 /Users/steven/Code/destination-small-town/vendor/webonyx/graphql-php/src/Executor/Executor.php(398): GraphQL\Executor\Executor->resolveField(Object(GraphQL\Type\Definition\ObjectType), NULL, Object(ArrayObject), Array)
#5 /Users/steven/Code/destination-small-town/vendor/webonyx/graphql-php/src/Executor/Executor.php(415): GraphQL\Executor\Executor->GraphQL\Executor\{closure}(Array, 'upsertTownNews', Array, Object(GraphQL\Type\Definition\ObjectType), NULL, Object(ArrayObject))
#6 /Users/steven/Code/destination-small-town/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php(135): GraphQL\Executor\Executor->GraphQL\Executor\{closure}(Array)
#7 /Users/steven/Code/destination-small-town/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php(35): GraphQL\Executor\Promise\Adapter\SyncPromise->GraphQL\Executor\Promise\Adapter\{closure}()
#8 /Users/steven/Code/destination-small-town/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromiseAdapter.php(140): GraphQL\Executor\Promise\Adapter\SyncPromise::runQueue()
#9 /Users/steven/Code/destination-small-town/vendor/webonyx/graphql-php/src/GraphQL.php(88): GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter->wait(Object(GraphQL\Executor\Promise\Promise))
#10 /Users/steven/Code/destination-small-town/vendor/markhuot/craftql/src/Services/GraphQLService.php(160): GraphQL\GraphQL::executeQuery(Object(GraphQL\Type\Schema), 'mutation newTow...', NULL, NULL, Array)
#11 /Users/steven/Code/destination-small-town/vendor/markhuot/craftql/src/Controllers/ApiController.php(125): markhuot\CraftQL\Services\GraphQLService->execute(Object(GraphQL\Type\Schema), 'mutation newTow...', Array)
#12 [internal function]: markhuot\CraftQL\Controllers\ApiController->actionIndex()
#13 /Users/steven/Code/destination-small-town/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#14 /Users/steven/Code/destination-small-town/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#15 /Users/steven/Code/destination-small-town/vendor/craftcms/cms/src/web/Controller.php(109): yii\base\Controller->runAction('index', Array)
#16 /Users/steven/Code/destination-small-town/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('index', Array)
#17 /Users/steven/Code/destination-small-town/vendor/craftcms/cms/src/web/Application.php(297): yii\base\Module->runAction('craftql/api/ind...', Array)
#18 /Users/steven/Code/destination-small-town/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('craftql/api/ind...', Array)
#19 /Users/steven/Code/destination-small-town/vendor/craftcms/cms/src/web/Application.php(286): yii\web\Application->handleRequest(Object(craft\web\Request))
#20 /Users/steven/Code/destination-small-town/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#21 /Users/steven/Code/destination-small-town/web/index.php(21): yii\base\Application->run()
(Sorry about changing the name of the issue a couple times. Just wanted to keep it relevant after finding out more about the issue!)
Has anyone else here experienced any similar issues when attempting basic mutations in 2.0.0 beta?
Yes, I'm seeing this too. I can update fine when providing the id of an existing entry, but trying to add a new entry returns the same result. I guess it's because the insert is failing and so then when the attempt to return results happens it finds nothing and throws this message. So what is actually going on is upserting is failing for some (validation?) reason.