Nested Metaobject Mutation help

Topic summary

Problem: How to populate list fields (references to other metaobjects) in a Shopify GraphQL CreateMetaobject mutation.

Context: A metaobject type “stateLawList” has fields:

  • state: Single line string
  • laws: List of MetaObjects of type “Law”
  • notes: List of MetaObjects of type “Note”

The “Law” and “Note” metaobjects already exist, and their handles are known. The user included a mutation variables snippet showing fields for state, laws, and notes, and asks what the value for the list fields should be.

Attempts and questions:

  • Tried an array of handles (failed) and a comma-separated list of handles (failed).
  • Unsure if an array/list of GIDs (global IDs) is required, or if the full metaobject must be passed.
  • Documentation suggests value must be a string; unclear how lists should be represented and whether arrays are accepted for list fields.

Status: No resolution yet; guidance requested. The code snippet is central to the issue.

Summarized with AI on January 27. AI used: gpt-5.

I have a metaobject that has the following structure:

State - Single Line String

Laws - List of MetaObjects of type “Law”

Notes - List of MetaObjects of type “Note”

My question is how do I construct a mutation and variables to populate the list of Law and Note MetaObjects?

The individual “Law” and “Note” metaobjects have been created and I have their handles.

Variable definition for the CreateMetaobject mutation:

{
      capabilities: {
        publishable: {
          status: "ACTIVE"
        }
      },                 
    type: "stateLawList",
    handle: `${ samHandle.toLowerCase()}`,
    fields: [
        {
            key: "state",
            value: state
        },
        {
            key: "laws",
            value: ??List of Law MetaObjects??
        },
        {
            key: "notes",
            value: ??List of Note MetaObjects??
        }
    ]
  }

What should the “value” property look like in my variables passed to the CreateMetaobject mutation???

I tried an array of handles and that was a failure. Also tried a comma separated list of handles.

Have not tried an array or list of gids. Or do I need to query each Law and Note and pass the entire metaobject as a field value?

If the field is defined as a list, can you supply an array of values? In looking at the documentation it sure looks like the “value” field needs to be a string.

A bit confused can someone help?

Thanks,

Dan