Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Error display if token permissions are incorrect #146

Open
khalwat opened this issue Aug 27, 2018 · 1 comment
Open

Error display if token permissions are incorrect #146

khalwat opened this issue Aug 27, 2018 · 1 comment

Comments

@khalwat
Copy link

khalwat commented Aug 27, 2018

I am writing a mutation to add an entry; it was failing with a 500 internal server error:

2018-08-27 10:06:01 [192.168.10.1][1][-][error][yii\base\UnknownMethodException] yii\base\UnknownMethodException: Calling unknown method: markhuot\CraftQL\Builders\InputSchema::createInputObjectType() in /home/vagrant/sites/craft3/vendor/yiisoft/yii2/base/Component.php:300
Stack trace:
#0 /home/vagrant/sites/craft3/vendor/markhuot/craftql/src/FieldBehaviors/EntryQueryArguments.php(60): yii\base\Component->__call('createInputObje...', Array)
#1 /home/vagrant/sites/craft3/vendor/markhuot/craftql/src/FieldBehaviors/EntryQueryArguments.php(39): markhuot\CraftQL\FieldBehaviors\EntryQueryArguments->relatedToInputObject()
#2 [internal function]: markhuot\CraftQL\FieldBehaviors\EntryQueryArguments->initEntryQueryArguments()
#3 /home/vagrant/sites/craft3/vendor/yiisoft/yii2/base/Component.php(297): call_user_func_array(Array, Array)
#4 /home/vagrant/sites/craft3/vendor/markhuot/craftql/src/Builders/BaseBuilder.php(32): yii\base\Component->__call('initEntryQueryA...', Array)
#5 /home/vagrant/sites/craft3/vendor/markhuot/craftql/src/Builders/InputSchema.php(32): markhuot\CraftQL\Builders\BaseBuilder->bootBehaviors()
#6 /home/vagrant/sites/craft3/vendor/markhuot/craftql/src/Builders/InputSchema.php(40): markhuot\CraftQL\Builders\InputSchema->getArguments()
#7 [internal function]: markhuot\CraftQL\Builders\InputSchema->markhuot\CraftQL\Builders\{closure}()
#8 /home/vagrant/sites/craft3/vendor/webonyx/graphql-php/src/Type/Definition/InputObjectType.php(61): call_user_func(Object(Closure))
#9 /home/vagrant/sites/craft3/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php(125): GraphQL\Type\Definition\InputObjectType->getFields()
#10 /home/vagrant/sites/craft3/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php(134): GraphQL\Utils\TypeInfo::extractTypes(Object(GraphQL\Type\Definition\InputObjectType), Array)
#11 /home/vagrant/sites/craft3/vendor/webonyx/graphql-php/src/Type/Schema.php(223): GraphQL\Utils\TypeInfo::extractTypes(Object(GraphQL\Type\Definition\InputObjectType), Array)
#12 /home/vagrant/sites/craft3/vendor/webonyx/graphql-php/src/Type/Schema.php(195): GraphQL\Type\Schema->collectAllTypes()
#13 /home/vagrant/sites/craft3/vendor/webonyx/graphql-php/src/Type/Schema.php(137): GraphQL\Type\Schema->getTypeMap()
#14 /home/vagrant/sites/craft3/vendor/markhuot/craftql/src/Services/GraphQLService.php(113): GraphQL\Type\Schema->__construct(Object(GraphQL\Type\SchemaConfig))
#15 /home/vagrant/sites/craft3/vendor/markhuot/craftql/src/Controllers/ApiController.php(116): markhuot\CraftQL\Services\GraphQLService->getSchema(Object(markhuot\CraftQL\Models\Token))
#16 [internal function]: markhuot\CraftQL\Controllers\ApiController->actionIndex()
#17 /home/vagrant/sites/craft3/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#18 /home/vagrant/sites/craft3/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#19 /home/vagrant/sites/craft3/vendor/craftcms/cms/src/web/Controller.php(103): yii\base\Controller->runAction('index', Array)
#20 /home/vagrant/sites/craft3/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('index', Array)
#21 /home/vagrant/sites/craft3/vendor/craftcms/cms/src/web/Application.php(282): yii\base\Module->runAction('craftql/api/ind...', Array)
#22 /home/vagrant/sites/craft3/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('craftql/api/ind...', Array)
#23 /home/vagrant/sites/craft3/vendor/craftcms/cms/src/web/Application.php(271): yii\web\Application->handleRequest(Object(craft\web\Request))
#24 /home/vagrant/sites/craft3/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#25 /home/vagrant/sites/craft3/web/index.php(17): yii\base\Application->run()
#26 {main}
2018-08-27 10:06:01 [192.168.10.1][1][-][info][application] $_GET = []

As it turns out, the Bearer token just needed to have Query in addition to Mutation permissions on the Section in question.

Perhaps the error reporting could be more explicit that the issue is a one of permissions in cases like this (and others)?

@markhuot
Copy link
Owner

markhuot commented Sep 7, 2018

This is actually a bug, you should be able to upsert without needing to also query. I've fixed this on dev-master.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants