Get Metaobject reference within another Metaobject GraphQL query

Topic summary

A developer is encountering a null value when attempting to query a Metaobject reference within another Metaobject using GraphQL.

Setup:

  • Querying metaobjects of type “my_text”
  • Each entry contains a reference field (“body_text”) that should link to another Metaobject
  • The referenced object holds a category name needed for their implementation

Issue:

  • The references field returns null instead of the expected Metaobject data
  • Query structure attempts to access referenced Metaobject’s id and type fields

Current Status:

  • The developer is seeking validation on whether their GraphQL query structure is correct for accessing Metaobject references
  • No responses or solutions have been provided yet
  • The discussion remains open with the core question unanswered
Summarized with AI on November 10. AI used: claude-sonnet-4-5-20250929.

Hi, I’m seeing null when trying to access a Metaobject reference, within a Metaobject query.

The referenced object contains the category name, which is essential to my cause. There is 1 reference on each entry.

Is my structure OK for referencing this?

{
  metaobjects(type: "my_text", first: 50) {
    nodes {
      handle
      field(key: "body_text") {
        value
        references(first: 1) {
          edges {
            node {
              ... on Metaobject {
                id
                type
                fields {
                  key
                  value
                }
              }
            }
          }
        }
      }
      
    }
  }
}

Result:

"data": {
    "metaobjects": {
      "nodes": [
        {
          "handle": "xxxxxxxxxxxxx",
          "field": {
            "value": "Item 1",
            "references": null
          }
        },
        {
          "handle": "xxxxxxxxxxxx",
          "field": {
            "value": "Item 2",
            "references": null
          }
        }
    }
}
1 Like