Creating a metaobject that contains an image

Topic summary

Issue: A developer is working with Shopify’s GraphQL Admin API to programmatically add images to metaobjects. While they successfully created metaobject definitions with file_reference type fields and uploaded images to Shopify’s staging storage, they couldn’t connect the uploaded images to metaobject fields.

Key Challenge: Images uploaded via the staging process receive temporary URLs and appear in Shopify’s Content > Files with unique IDs, but the developer needed to understand how to reference these files in metaobject fields programmatically.

Solution Found:

  • Upload the file to Shopify using the documented media upload process
  • Retrieve the file’s GID (global ID) from the upload response
  • Use the GraphQL metaobjectUpdate mutation to assign the image by passing the file’s GID to the metaobject’s file field

Code Example Provided: A TypeScript mutation showing how to update a metaobject with the file GID, where the key is “file” and the value is the image’s GID.

Status: Resolved through community collaboration and reference to a GitHub gist documenting the multi-step process.

Summarized with AI on November 9. AI used: claude-sonnet-4-5-20250929.

Again, thanks for the help. Looks like that’s all you need. Push the file up from source URL, and grab the id and post that to the metaobject.