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.

Query MetaObjects by DisplayName

Solved

Query MetaObjects by DisplayName

Rjantsch
Shopify Partner
2 0 0

Hi,

 

I am building a checkout UI extension that is supposed to query all the metaobjects from a specific type. For example,  I have the Metaobject definition:

Rjantsch_0-1723558209688.png

 

When trying to run this query:

 
   const { data } = await query(
        `query (
            $type: String!,
            $sortKey: String,
            $first: Int
          ){
            metaobjects(
              type: $type,
              sortKey: $sortKey,
              first: $first,
            ) {
              nodes {
                id
                updatedAt
                displayName
                fields {
                  key
                  value
                }
              }
            }
          }`,
        {
          variables: { 
         
          "type": "vet",
          "sortKey": "id",
          "first": 10
          },
        }
      );
it tells me ""Field 'displayName' doesn't exist on type 'Metaobject'". According to the docs (https://shopify.dev/docs/api/admin-graphql/2024-07/queries/metaobjects), the return of this function should accept a displayName field, however it doesn't. What could be happening?
 
Thank you in advance!

 

Accepted Solution (1)

Liam
Community Manager
3108 344 904

This is an accepted solution.

Hi Rjantsch - are you using the Storefront API? If so that does not support displayName which could be why you're seeing this. 

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

View solution in original post

Reply 1 (1)

Liam
Community Manager
3108 344 904

This is an accepted solution.

Hi Rjantsch - are you using the Storefront API? If so that does not support displayName which could be why you're seeing this. 

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