A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I am using metafieldsSet graphQL 2022-07 to create and update my app.metafield
https://shopify.dev/docs/api/admin-graphql/2022-07/mutations/metafieldsSet
According to the documentation "Metafield values will be set regardless if they were previously created or not."
Why I received a deprecation call and why I forced to move the app to the new API 2023-01.
What is the query to check is app.metafield exists? (create if not and update if yes)
Solved! Go to the solution
This is an accepted solution.
Hi @lokki54,
I believe the deprecation notice is just letting you know that you should update your API version soon due to how our API versioning works, it's not specific to `metafieldsSet`. The API change listed there is just informational – if you have a metafield definition created, then you don't _need_ to send the `type` in your mutation. Because `metafieldsSet` works as an upsert, you don't need to check if the metafield exists.
To learn more visit the Shopify Help Center or the Community Blog.
This is an accepted solution.
Hi @lokki54,
I believe the deprecation notice is just letting you know that you should update your API version soon due to how our API versioning works, it's not specific to `metafieldsSet`. The API change listed there is just informational – if you have a metafield definition created, then you don't _need_ to send the `type` in your mutation. Because `metafieldsSet` works as an upsert, you don't need to check if the metafield exists.
To learn more visit the Shopify Help Center or the Community Blog.
Thank you for the reply! So I made an app 2022-07 and now after short time I have to refactor it to a new API version? Sound like not easy task coz I use shopify_app gem and can't just switch to the new shopify_api version
API versions are supported for a year, so you can expect to bump your APIs once per year. The dashboard will do a pretty good job of telling you what, if anything, you need to change when you bump the version. So I would grab the latest version of the gem and do some tests. In general we try to minimize breaking changes for partners. Just a note that if I were you I'd wait a few weeks to upgrade, as the newest API version is out April 1st and that would be the best time to do it. Hope that helps!
To learn more visit the Shopify Help Center or the Community Blog.
Thank you for the suggestion. I will wait for a new version.
However one thing is still not clear to me. Even on new API version will the metafieldsSet querry is sufficient to create_or_update with such input
{
"metafields": {
"key": "global_settings",
"namespace": "appname",
"ownerId": "myappinstallationID",
"type": "json",
"value": "somedatainjsonformat",
}
Or should I use separate queries to check if exist Update if not Create?
metafieldsSet is an upsert, so it will set the specified values whether or not they previously existed.
To learn more visit the Shopify Help Center or the Community Blog.