Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 2.67 KB

metafield-object.md

File metadata and controls

41 lines (27 loc) · 2.67 KB

Metafield object

{% hint style="danger" %} Important Notice


Shopify is deprecating the Shopify Admin REST API which the Mechanic REST objects depend on. The first round of deprecations involve the product and variant endpoints. Read about the deprecation here and here.

Use the GraphQL going forward. The product and variant objects will cease to work on on Feb 1, 2025 due to the changes being made by Shopify. Shopify will phase out the REST API completely over time, you can read more about this here.


All of our library tasks will be ported to use GraphQL only, which will provide a model for how you can update your custom tasks. You'll be able to update your non-customized library tasks with a click of a button ☺️

Please see these guides for migrating your custom tasks to GraphQL. {% endhint %}

{% hint style="info" %} This page is part of a series: see Metafields for an overview on how Mechanic's Liquid implementation thinks about metafields. {% endhint %}

The metafield object reflects the REST Admin API's representation of a metafield.

Mechanic includes support for the metafield object for completeness, but it is not the most useful way to go about using metafield values (see Metafield representation object).

What it contains

{% hint style="warning" %} For many metafield types (e.g. dimension, weight, decimal, etc), the value attribute of the metafield object is a JSON-encoded string. For most scalar types (e.g. boolean, number_integer), the value attribute has a matching type.

The simplest way to access a usable version of a metafield value is via the metafield representation object, i.e. resource.metafields.namespace.key.value. {% endhint %}

How to access it

  • For modern metafields, use resource.metafields.namespace.key.metafield to retrieve the metafield object itself.
  • For deprecated metafields, use resource.metafields.namespace.key to retrieve the parsed, appropriately-typed metafield value.