Manage metaobjects
Metaobjects enable app users and app developers to define custom objects in Shopify. This guide shows you how to get started with creating and managing metaobjects and metaobject definitions using the GraphQL Admin API.
Anchor to What you'll learnWhat you'll learn
In this tutorial, you'll learn how to do the following tasks:
- Define metaobjects
- Create metaobject entries
Anchor to RequirementsRequirements
- Your app can make authenticated requests to the GraphQL Admin API.
- You're using API version 2023-01 or higher.
Anchor to ScenarioScenario
You want your app to offer a way for users to create highlights for products they're creating. Users might want to showcase the quality of their goods or interesting facts about the product.
Anchor to Step 1: Define a product highlight metaobjectStep 1: Define a product highlight metaobject
Before users can start creating highlights, your app will need to tell Shopify what a product highlight is. Shopify doesn't have a product highlight resource, so you need to define one using the metaobjectDefinitionCreate
mutation:
The following example uses $app:product_highlights
as its reserved type. Refer to ownership to learn more about reserved types and prefixes.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to Step 2: Create a product highlight metaobject entryStep 2: Create a product highlight metaobject entry
After defining what a product highlight is, you can create entries or instances of your product highlights using the metaobjectCreate
mutation:
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to Step 3: Retrieve your product highlightsStep 3: Retrieve your product highlights
With your product highlight entry now created, you can read it back from the API using the metaobjects
paginated query to retrieve all of your highlights:
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL query
JSON response
You can also retrieve a single metaobject by its handle using the metaobjectByHandle
query:
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL query
JSON response
Anchor to Next stepsNext steps
- Learn more about access controls.
- Learn about metaobject capabilities.
- Learn about the limits on how many metaobject definitions and entries can be created.