App Owned Metaobject Access in Liquid

RiptideApps
Shopify Partner
11 0 1

Hi there!

I am working on building an app which creates custom metaobject definition and objects using the Admin API / GraphQL. I cannot figure out how to access it from my Theme App Extension / Embed? From the documentation (The Documentation), it seemed like I should be able to add the storefront access as seen below in the definition.

 

I verified via my API that I can create/edit/retrieve objects, and that they are set to published status 'ACTIVE'.

 

 

The definition is below:

 

 

{
  name: "xxxxxxxxxx",
  type: "$app:xxxxxxxxxx",
  description: "xxxxxxxxxx",
  fieldDefinitions: [
    {
      description: "xxxxxxxxxx",
      key: "xxxxxxxxxx_json",
      name: "xxxxxxxxxx JSON",
      required: true,
      type: "json",
      validations: [],
    },
  ],
  access: {
    admin: "MERCHANT_READ",
    storefront: "PUBLIC_READ",
  },
  capabilities: {
    publishable: {
      enabled: true,
    },
    translatable: {
      enabled: false,
    },
  },
}

 

 

 

I feel like I have tried every combination of liquid similar to the following:

 

 

{{ shop.metaobjects['type'].values }}
{{ app.metaobjects['type'].values }}
{{ shop.metaobjects['$app:type'].values }}
{{ app.metaobjects['$app:type'].values }}
{{ app.metafields.values }}

 

 

EDIT: Adding link to another developer's post explaining the exact issue wwe are seeing: How to access app owned meta object in theme app extensions's liquid file?
https://community.shopify.com/c/technical-q-a/how-to-access-app-owned-meta-object-in-theme-app-exten... 

Replies 2 (2)
Liam
Shopify Staff
Shopify Staff
1373 130 436

 

Hi  RiptideApps,

 

Have you tried this format to access an app's metafields in Liquid:

{{ app.metafields.namespace.key }}

 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

RiptideApps
Shopify Partner
11 0 1

So, based on this metaobject data (retrieved from GraphQL API), I tried the following combinations...

{
  capabilities: {
    publishable: {
      status: "ACTIVE",
    },
  },
  definition: {
    id: "gid://shopify/MetaobjectDefinition/XXXXXXX",
    name: "XXXXXXXXXXX",
    type: "app--XXXXXXXX--XXXXXXX_XXXX",
    access: {
      admin: "MERCHANT_READ",
      storefront: "PUBLIC_READ",
    },
  },
  fields: [
    {
      value: "[{XXXX_JSON_DATA_XXXXX}]",
      key: "XXXX__KEY_NAME__XXXX_json",
    },
  ],
  displayName: "App  XXXXXXXXXX XXXXX #MSXXXXXXXX",
  handle: "app--XXXXXXXXX--XXXX-XXXXX-XXXXXXXX",
  id: "gid://shopify/Metaobject/XXXXXXXXX",
  type: "app--XXXXXXXXXXX--XXXX__METAOBJ_DEF_TYPE__XXXX",
  updatedAt: "2023-09-17T04:49:02Z",
}

 

    "{{ app.metafields.XXXX__METAOBJ_DEF_TYPE__XXXX.XXXX__KEY_NAME__XXXX.value | json }}",
    "{{ app.metafields.XXXX__METAOBJ_DEF_TYPE__XXXX.XXXX__KEY_NAME__XXXX}}",
    "{{ app.metafields.XXXX__METAOBJ_DEF_TYPE__XXXX.XXXX__KEY_NAME__XXXX.value }}",
    "{{ app.metafields.XXXX__METAOBJ_DEF_TYPE__XXXX.XXXX__KEY_NAME__XXXX | json }}"

/** 
** Note: I am NOT including the "$app:" prefix
**  or the "app-123456" prefix to any of the types above
**/