What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

create app.metafiled with metafieldsSet

Solved

create app.metafiled with metafieldsSet

lokki54
Shopify Partner
55 0 15

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.

depr.jpg

 

What is the query to check is app.metafield exists? (create if not and update if yes)

Accepted Solution (1)

richard-penner
Shopify Staff
19 2 6

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.

View solution in original post

Replies 5 (5)

richard-penner
Shopify Staff
19 2 6

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.

lokki54
Shopify Partner
55 0 15

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

richard-penner
Shopify Staff
19 2 6

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.

lokki54
Shopify Partner
55 0 15

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?

richard-penner
Shopify Staff
19 2 6

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.