craftcms / gatsby-source-craft

Gatsby source plugin for Craft CMS.
MIT License
54 stars 13 forks source link

Deprecation Warnings in Craft when sourcing data #59

Closed andreasottosson closed 3 years ago

andreasottosson commented 3 years ago

Description

Craft show the following errors under "Deprecation Warnings" when running the source plugin.

43  Deprecation error: Elements’ getSourceId() method has been deprecated. Use getCanonicalId() instead.
Called from /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/base/Element.php:2323

42  craft\elements\Entry::getSourceId()
Called from /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/base/Component.php:140

41  craft\elements\Entry::__get("sourceId")
Called from /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/base/Element.php:1736

40  craft\elements\Entry::__get("sourceId")
Called from /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/gql/base/ObjectType.php:73

39  craft\gql\types\elements\Entry::resolve(craft\elements\Entry, [], ["conditionBuilder" => craft\gql\ElementQueryConditionBuilder, "argumentManager" => craft\gql\ArgumentManager], GraphQL\Type\Definition\ResolveInfo)
Called from /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/gql/types/elements/Element.php:54

38  craft\gql\types\elements\Entry::resolve(craft\elements\Entry, [], ["conditionBuilder" => craft\gql\ElementQueryConditionBuilder, "argumentManager" => craft\gql\ArgumentManager], GraphQL\Type\Definition\ResolveInfo)
Called from /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/gql/types/elements/Entry.php:65

...

Steps to reproduce

  1. Install this plugin
  2. Source some data

Additional info

andris-sevcenko commented 3 years ago

I've made it so that sourceId won't be used in node ids if Craft is at version 3.7 or later, but that's all that can be done without some not-very-stable changes.

Even though the fields (sourceId, sourceUid) are deprecated, Gatsby GraphQL Toolkit still includes them in the fragments that are generated by default. Theoretically, I could try to intercept that and remove them from the schema as the data goes screaming by, but that's a little too unstable of a strategy.

Those fields will be removed in Craft 4.0, but, meanwhile, you'll have to work around that by removing sourceId and sourceUid from the generated fragments (https://github.com/craftcms/gatsby-source-craft#customizing-generated-fragments).

Also, the changes mentioned above will take place when we release version 2.1 of the sourcing plugin - hopefully today!