Where is valueType in MetafieldInput?

Keita_W
Shopify Partner
4 0 4

Hello

"valueType" in MetafieldInput was lost?
https://shopify.dev/api/admin/graphql/reference/metafields/metafieldinput
now.png

I can see "valueType" in Google cache of the same page.
https://webcache.googleusercontent.com/search?q=cache:m3CXWtM7DncJ:https://shopify.dev/docs/admin-ap...
cache-image.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

What's happen??

Thank you.

Replies 10 (10)
iozyigit
Shopify Partner
23 1 2

Says will depricate in new version of api but I am using 2021-04 and disappeared. I can't see "type' either.

"deprecationReason": "`valueType` is deprecated and replaced by `type` in API version 2021-07."
Screen Shot 2021-07-03 at 2.00.29 PM.png

https://www.linkedin.com/in/ismailozyigit/
jake___
Shopify Partner
4 0 0

Yep, can confirm. valueType has disappeared on MetafieldInput and Metafield objects. REST API docs are being displayed fine with a deprecation of 2021-07. In addition, these deprecation notices are not listed on https://shopify.dev/api/release-notes/2021-07, and they are also not causing warnings in App's API Health.

Moreover, changelog here states the deprecation will only happen in 2021-10: https://shopify.dev/changelog/online-store-2-0-new-metafields-type-system-and-dynamic-sources, but here it states the deprecation is 2021-07: https://shopify.dev/apps/metafields/manage#using-type-vs-value_type

Also, when querying the new type parameter on metafields, it is returning json_string instead of just json (json_string does not exist according to https://shopify.dev/apps/metafields/definitions/types -- it has been replaced by json)

I'm incredibly confused here... these inconsistencies are preventing me from upgrading our app to the 2021-07 API. Shopify, can you please clarify?

Dave_Pelletier
Shopify Staff
Shopify Staff
27 3 3

Sorry for the confusion! We'll be updating each of those pages that Jake linked to make the situation more clear. Here's what you need to know about this transition:

  • The `type: String` field is replacing the old `value_type: MetafieldValueType` field
  • You can see the new list of type values in our dev docs here. Some of those types map directly to the old MetafieldValueType enum, but we had to make an exception for json_string (the old value_type) and json (the new type). The deprecated "json_string" type will continue to exist because it behaves differently than the new "json" type when referenced in Liquid.
  • In 2021-07 we added type and deprecated value_type
  • In 2021-10 we will be removing value_type entirely
  • This transition is phased over two API releases so that you can upgrade to 2021-07 and start switching to the new type field without breaking any of your existing API calls that rely on value_type
Keita_W
Shopify Partner
4 0 4

Thank you for your response.

However, it is not my issue.
My issue is that valueType is removed in older version API references.
https://shopify.dev/api/admin/graphql/reference/metafields/metafieldinput?api%5Bversion%5D=2021-04

Version 2021-04 should have valueType, but I cannot see.

Please check and modify the API references.

Thank you.

jake___
Shopify Partner
4 0 0

Hi Dave,

Thanks for the clarification!

So we can upgrade to 2021-07 without the need of updating value_type to type? Then only when upgrading to 2021-10, we will need to ensure we fully migrated to type? Finally, this change will follow the usual deprecation lifeycle (i.e. that is, we will have 9 months to update our apps to 2021-10 on October 1st 2021)?

What's the difference between json_string and json? Can we use the JSON Liquid filter still on the new  json type (e.g. {{product.metafields.foo.bar | json}})?

Thanks!

Dave_Pelletier
Shopify Staff
Shopify Staff
27 3 3

Hi Jake,

Your description of the deprecation and upgrade process is correct, with one change. We decided to delay the removal of value_type until 2022-01. It's still deprecated in 2021-10.

Going forward you should use json instead of json_string. You can use the json liquid filter on the new json type but you need to add .value: {{ product.metafields.foo.bar.value | json }}

Dave

jake___
Shopify Partner
4 0 0

Hi Dave,

Thanks for confirming that -- I was curious to why I was still able to use value_type on 2021-10 and also to why no API Health Alerts were being flagged on our production app.

After value_type (REST) and valueType (GraphQL) is deprecated, we can still continue to use the deprecated json_string, string, and integer on type, correct? From my understanding, this document here, https://shopify.dev/apps/metafields/manage.md#migrating-from-value_type-to-type, points in this direction but some additional clarification would be great here.

Also, the maximum value length has been published in the docs for string: 5 million chars, integer: 100k chars and json_string: 100k chars. What are the maximum lengths for the new type system? I do not see them here: https://shopify.dev/apps/metafields/definitions/types. Is this something that Shopify can clarify in their docs?

Thanks!

Dave_Pelletier
Shopify Staff
Shopify Staff
27 3 3

You are correct that you'll still be able to use the old json_string, string, and integer types with the new type field. We do encourage you to migrate to json, single_line_text_field, multi_line_text_field, or number_integer if you can. You'll have a more consistent experience (for example, in Liquid) by using the new types everywhere.

I'll try to find those max value/length restrictions and get them into our docs soon, thanks for pointing that out.

jake___
Shopify Partner
4 0 0

Hi Dave,

Thanks for your reply! A question with Liquid I have:

Using the string type, I can output the string into a Javascript variable as follows:

<script>
const old = {{ shop.metafields.global.foo | json }};
</script>

Using the new multi_line_text_field type, I can output the string into a Javascript variable as follows:

<script>
const new = {{ shop.metafields.global.bar.value | json }};
</script>

Both of these examples yield the exact same output for me. However, is this always the case? In other words, is this the correct way to migrate our Liquid code from string to multi_line_text_field? Is there anything I should be aware of? For example, using the new type field could escape the string -- e.g. Liquid turning the string 'hello into \'hello (a Javascript escape) or &hello into &amp;hello (a HTML escape)?

Thanks!

iozyigit
Shopify Partner
23 1 2

Thanks @Dave_Pelletier ,

So one more thing:

I did updated to 20-07-01 and had to make type to  'lowercase'. My generated code  was giving enum values as uppercase like below:

Screen Shot 2021-10-07 at 2.39.27 PM.png

I just realize in the documentation the value type was lowercase for "json_string". https://shopify.dev/apps/metafields/definitions/types. so I did like below and it was accepted.

Screen Shot 2021-10-07 at 2.40.50 PM.png

https://www.linkedin.com/in/ismailozyigit/