Query MetaObjects by DisplayName

Topic summary

Issue: A checkout UI extension querying Metaobjects by type fails with “Field ‘displayName’ doesn’t exist on type ‘Metaobject’” when requesting displayName.

Context: The query uses metaobjects(type, sortKey, first) and requests id, updatedAt, displayName, and fields { key, value }. The docs referenced are for the Admin GraphQL API (2024-07), where Metaobject includes displayName.

Diagnosis: A responder suggests the extension may be using the Storefront API. In the Storefront API, Metaobject does not expose displayName, which explains the error, whereas the Admin GraphQL API does.

Implications/next steps:

  • Verify which API the extension is calling (Storefront vs Admin).
  • If using Storefront API, remove displayName from the selection set or rely on specific fields within fields to represent a name.
  • If displayName is required, fetch via the Admin GraphQL API from a server-side context.

Status: No confirmed resolution yet; likely API mismatch causing the error.

Summarized with AI on December 21. AI used: gpt-5.

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:

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!

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