craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

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

Open GustavTaxen opened 9 months ago

GustavTaxen commented 9 months ago

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

i-just commented 9 months ago

Hi, thanks for getting in touch! Are you asking for a sourceId to be returned in your query? If yes, then you should change that to canonicalId to get rid of the deprecation error.

GustavTaxen commented 9 months ago

No, we don't ask specifically for a sourceId in any of our GraphQL queries. We ask for id in many of them, though.

On 31 Jan 2024, at 15:57, Iwona Just @.***> wrote:

Hi, thanks for getting in touch! Are you asking for a sourceId to be returned in your query? If yes, then you should change that to canonicalId to get rid of the deprecation error.

— Reply to this email directly, view it on GitHub https://github.com/craftcms/cms/issues/14254#issuecomment-1919274168, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSCUSLASS6IZCAFAE574JLYRJLWJAVCNFSM6AAAAABCSSJOVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJZGI3TIMJWHA. You are receiving this because you authored the thread.

i-just commented 9 months ago

Thanks for confirming. I’m unable to replicate this, nor can I see any references to sourceId that could cause this in Craft’s code. Could you please share one simple query that results in the deprecation warning being logged (along with info on what element types and fields are used in it)?