craftcms / craftcms/cms

[4.x]: Deprecation warnings from GraphQL API requests

Open
#14,254 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug craft4
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

What happened?
Description

We get this deprecation warning in the control panel. Does this mean that we using the GraphQL API incorrectly?

36 | Deprecation error: Elements’ getSourceId() method has been deprecated. Use getCanonicalId() instead.Called from /app/vendor/craftcms/cms/src/base/Element.php:2818
-- | --
craft\elements\Entry::getSourceId()Called from /app/vendor/yiisoft/yii2/base/Component.php:139
craft\elements\Entry::__get("sourceId")Called from /app/vendor/craftcms/cms/src/base/Element.php:2188
craft\elements\Entry::__get("sourceId")Called from /app/vendor/craftcms/cms/src/gql/base/ObjectType.php:72
craft\gql\types\elements\Entry::resolve(craft\elements\Entry, [], ["conditionBuilder" => craft\gql\ElementQueryConditionBuilder, "argumentManager" => craft\gql\ArgumentManager], GraphQL\Type\Definition\ResolveInfo)Called from /app/vendor/craftcms/cms/src/gql/types/elements/Element.php:79
craft\gql\types\elements\Entry::resolve(craft\elements\Entry, [], ["conditionBuilder" => craft\gql\ElementQueryConditionBuilder, "argumentManager" => craft\gql\ArgumentManager], GraphQL\Type\Definition\ResolveInfo)Called from /app/vendor/craftcms/cms/src/gql/types/elements/Entry.php:51
craft\gql\types\elements\Entry::resolve(craft\elements\Entry, [], ["conditionBuilder" => craft\gql\ElementQueryConditionBuilder, "argumentManager" => craft\gql\ArgumentManager], GraphQL\Type\Definition\ResolveInfo)Called from /app/vendor/craftcms/cms/src/gql/base/ObjectType.php:47
craft\gql\types\elements\Entry::resolveWithDirectives(craft\elements\Entry, [], ["conditionBuilder" => craft\gql\ElementQueryConditionBuilder, "argumentManager" => craft\gql\ArgumentManager], GraphQL\Type\Definition\ResolveInfo)Called from /app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:623
GraphQL\Executor\ReferenceExecutor::resolveFieldValueOrError(GraphQL\Type\Definition\FieldDefinition, GraphQL\Language\AST\FieldNode, [craft\gql\types\elements\Entry, "resolveWithDirectives"], craft\elements\Entry, ...)Called from /app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:550
GraphQL\Executor\ReferenceExecutor::resolveField(craft\gql\types\elements\Entry, craft\elements\Entry, ArrayObject, ["entries", 12, "sourceId"])Called from /app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:1195
GraphQL\Executor\ReferenceExecutor::executeFields(craft\gql\types\elements\Entry, craft\elements\Entry, ["entries", 12], ArrayObject)Called from /app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:1145
GraphQL\Executor\ReferenceExecutor::collectAndExecuteSubfields(craft\gql\types\elements\Entry, ArrayObject, ["entries", 12], craft\elements\Entry)Called from /app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:1106
GraphQL\Executor\ReferenceExecutor::completeObjectValue(craft\gql\types\elements\Entry, ArrayObject, GraphQL\Type\Definition\ResolveInfo, ["entries", 12], ...)Called from /app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:974
GraphQL\Executor\ReferenceExecutor::completeAbstractValue(GraphQL\Type\Definition\InterfaceType, ArrayObject, GraphQL\Type\Definition\ResolveInfo, ["entries", 12], ...)Called from /app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:789
GraphQL\Executor\ReferenceExecutor::completeValue(GraphQL\Type\Definition\InterfaceType, ArrayObject, GraphQL\Type\Definition\ResolveInfo, ["entries", 12], ...)Called from /app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:654
GraphQL\Executor\ReferenceExecutor::completeValueCatchingError(GraphQL\Type\Definition\InterfaceType, ArrayObject, GraphQL\Type\Definition\ResolveInfo, ["entries", 12], ...)Called from /app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:887
GraphQL\Executor\ReferenceExecutor::completeListValue(GraphQL\Type\Definition\ListOfType, ArrayObject, GraphQL\Type\Definition\ResolveInfo, ["entries"], ...)Called from /app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:761
GraphQL\Executor\ReferenceExecutor::completeValue(GraphQL\Type\Definition\ListOfType, ArrayObject, GraphQL\Type\Definition\ResolveInfo, ["entries"], ...)Called from /app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:654
GraphQL\Executor\ReferenceExecutor::completeValueCatchingError(GraphQL\Type\Definition\ListOfType, ArrayObject, GraphQL\Type\Definition\ResolveInfo, ["entries"], ...)Called from /app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:557
GraphQL\Executor\ReferenceExecutor::resolveField(GraphQL\Type\Definition\ObjectType, null, ArrayObject, ["entries"])Called from /app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:1195
GraphQL\Executor\ReferenceExecutor::executeFields(GraphQL\Type\Definition\ObjectType, null, [], ArrayObject)Called from /app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:264
GraphQL\Executor\ReferenceExecutor::executeOperation(GraphQL\Language\AST\OperationDefinitionNode, null)Called from /app/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:215
GraphQL\Executor\ReferenceExecutor::doExecute()Called from /app/vendor/webonyx/graphql-php/src/Executor/Executor.php:156
GraphQL\Executor\Executor::promiseToExecute(GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter, GraphQL\Type\Schema, GraphQL\Language\AST\DocumentNode, null, ...)Called from /app/vendor/webonyx/graphql-php/src/GraphQL.php:162
GraphQL\GraphQL::promiseToExecute(GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter, GraphQL\Type\Schema, " { entries(dateUpdated: ">2024-01-05 13:44:17", orderBy:...", null, ...)Called from /app/vendor/webonyx/graphql-php/src/GraphQL.php:94
GraphQL\GraphQL::executeQuery(GraphQL\Type\Schema, " { entries(dateUpdated: ">2024-01-05 13:44:17", orderBy:...", null, ["conditionBuilder" => craft\gql\ElementQueryConditionBuilder, "argumentManager" => craft\gql\ArgumentManager], ...)Called from /app/vendor/craftcms/cms/src/services/Gql.php:514
craft\services\Gql::executeQuery(craft\models\GqlSchema, " { entries(dateUpdated: ">2024-01-05 13:44:17", orderBy:...", null, null, ...)Called from /app/vendor/craftcms/cms/src/controllers/GraphqlController.php:195
craft\controllers\GraphqlController::actionApi()
call_user_func_array([craft\controllers\GraphqlController, "actionApi"], [])Called from /app/vendor/yiisoft/yii2/base/InlineAction.php:57
yii\base\InlineAction::runWithParams([])Called from /app/vendor/yiisoft/yii2/base/Controller.php:178
craft\controllers\GraphqlController::runAction("api", [])Called from /app/vendor/yiisoft/yii2/base/Module.php:552
craft\web\Application::runAction("graphql/api", [])Called from /app/vendor/craftcms/cms/src/web/Application.php:305
craft\web\Application::runAction("graphql/api", [])Called from /app/vendor/yiisoft/yii2/web/Application.php:103
craft\web\Application::handleRequest(craft\web\Request)Called from /app/vendor/craftcms/cms/src/web/Application.php:290
craft\web\Application::handleRequest(craft\web\Request)Called from /app/vendor/yiisoft/yii2/base/Application.php:384
craft\web\Application::run()Called from /app/web/index.php:26
Craft CMS version

4.6.1

PHP version

8.1.27

Operating system and version

Linux 4.15.0-197-generic

Database type and version

MySQL 47

Image driver and version

Imagick 3.7.0 (ImageMagick 7.1.1-13)

Installed plugins and versions
  • Feed Me 5.3.0
  • Redactor 3.0.4
  • Retour 4.1.14

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with craft\gql\types\elements\Entry::resolve and craft\gql\base\ObjectType.php in the stack trace, then reproduce the entries GraphQL request that selects sourceId. Done means the request no longer emits the getSourceId() deprecation warning; verify it against the reported Craft 4.6.1 environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, php
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.