Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Cannot Query Field with handle author via GraphQL (Internal Server Error) #7625

Closed
reilnuud opened this issue Feb 26, 2021 · 2 comments
Closed

Comments

@reilnuud
Copy link

Description

Created an entry field with the handle author on a channel entry type. Kept getting an internal server error. Changed the handle to authors and it worked. It looks like Craft is trying to lookup the User who created the entry rather than the field, but gets confused doing so.

If the underlying problem cannot be resolved without significant refactoring, my recommendation would be to add author to the list of reserved words.

Steps to reproduce

  1. Create an entry field type on an an entry with the handle author.
  2. Query the entry field with GraphQL.
  3. Get Internal Server Error resposne.

Additional info

  • Craft version: 3.6.7
  • PHP version: 7.4
  • Database driver & version: mysql Ver 14.14 Distrib 5.7.33, for Linux (x86_64)
  • Plugins & versions: N/A

relevant error message:

[error][yii\base\UnknownPropertyException] yii\base\UnknownPropertyException: Setting unknown property: craft\elements\db\UserQuery::typeId in [ROOT]/vendor/yiisoft/yii2/base/Component.php:210
Stack trace:
#0 [ROOT]/vendor/craftcms/cms/src/elements/db/ElementQuery.php(544): yii\base\Component->__set('typeId', Array)
#1 [ROOT]/vendor/craftcms/cms/src/elements/db/UserQuery.php(191): craft\elements\db\ElementQuery->__set('typeId', Array)
#2 [ROOT]/vendor/yiisoft/yii2/BaseYii.php(558): craft\elements\db\UserQuery->__set('typeId', Array)
#3 [ROOT]/vendor/craftcms/cms/src/services/Elements.php(2100): yii\BaseYii::configure(Object(craft\elements\db\UserQuery), Array)
#4 [ROOT]/vendor/craftcms/cms/src/services/Elements.php(2207): craft\services\Elements->_eagerLoadElementsInternal('craft\\elements\\...', Array, Array)
#5 [ROOT]/vendor/craftcms/cms/src/services/Elements.php(2026): craft\services\Elements->_eagerLoadElementsInternal('craft\\elements\\...', Array, Array)
#6 [ROOT]/vendor/craftcms/cms/src/elements/db/ElementQuery.php(2963): craft\services\Elements->eagerLoadElements('craft\\elements\\...', Array, Array)
#7 [ROOT]/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1484): craft\elements\db\ElementQuery->_createElements(Array)
#8 [ROOT]/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1538): craft\elements\db\ElementQuery->populate(Array)
#9 [ROOT]/vendor/craftcms/cms/src/gql/base/ElementResolver.php(40): craft\elements\db\ElementQuery->one()
#10 [ROOT]/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(624): craft\gql\base\ElementResolver::resolveOne(NULL, Array, Array, Object(GraphQL\Type\Definition\ResolveInfo))
#11 [ROOT]/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(550): GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError(Object(GraphQL\Type\Definition\FieldDefinition), Object(GraphQL\Language\AST\FieldNode), 'craft\\gql\\resol...', NULL, Object(GraphQL\Type\Definition\ResolveInfo))
#12 [ROOT]/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1196): GraphQL\Executor\ReferenceExecutor->resolveField(Object(GraphQL\Type\Definition\ObjectType), NULL, Object(ArrayObject), Array)
#13 [ROOT]/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(264): GraphQL\Executor\ReferenceExecutor->executeFields(Object(GraphQL\Type\Definition\ObjectType), NULL, Array, Object(ArrayObject))
#14 [ROOT]/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(215): GraphQL\Executor\ReferenceExecutor->executeOperation(Object(GraphQL\Language\AST\OperationDefinitionNode), NULL)
#15 [ROOT]/vendor/webonyx/graphql-php/src/Executor/Executor.php(156): GraphQL\Executor\ReferenceExecutor->doExecute()
#16 [ROOT]/vendor/webonyx/graphql-php/src/GraphQL.php(162): GraphQL\Executor\Executor::promiseToExecute(Object(GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter), Object(GraphQL\Type\Schema), Object(GraphQL\Language\AST\DocumentNode), NULL, Array, Array, NULL, NULL)
#17 [ROOT]/vendor/webonyx/graphql-php/src/GraphQL.php(94): GraphQL\GraphQL::promiseToExecute(Object(GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter), Object(GraphQL\Type\Schema), '{\n  entry(secti...', NULL, Array, Array, NULL, NULL, Array)
#18 [ROOT]/vendor/craftcms/cms/src/services/Gql.php(544): GraphQL\GraphQL::executeQuery(Object(GraphQL\Type\Schema), '{\n  entry(secti...', NULL, Array, Array, NULL, NULL, Array)
#19 [ROOT]/vendor/craftcms/cms/src/controllers/GraphqlController.php(172): craft\services\Gql->executeQuery(Object(craft\models\GqlSchema), '{\n  entry(secti...', Array, NULL, true)
#20 [internal function]: craft\controllers\GraphqlController->actionApi()
#21 [ROOT]/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#22 [ROOT]/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#23 [ROOT]/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('api', Array)
#24 [ROOT]/vendor/yiisoft/yii2/base/Module.php(534): craft\web\Controller->runAction('api', Array)
#25 [ROOT]/vendor/craftcms/cms/src/web/Application.php(274): yii\base\Module->runAction('graphql/api', Array)
#26 [ROOT]/vendor/yiisoft/yii2/web/Application.php(104): craft\web\Application->runAction('graphql/api', Array)
#27 [ROOT]/vendor/craftcms/cms/src/web/Application.php(259): yii\web\Application->handleRequest(Object(craft\web\Request))
#28 [ROOT]/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#29 [ROOT]/web/index.php(22): yii\base\Application->run()
#30 {main}
@reilnuud reilnuud added the bug label Feb 26, 2021
@andris-sevcenko
Copy link
Contributor

This is a duplicate of #2797

Unfortunately, it's not possible to use getFieldValue() in GraphQL, so you definitely won't be able to use an author custom field on entries in GraphQL until #1524 gets resolved.

@brandonkelly
Copy link
Member

For posterity, this is resolved for Craft 3.7.

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

No branches or pull requests

3 participants