Skip to content
OpenSmartRoute
Skillv1.0.0

shopify-metafields-metaobjects

Model custom data with Shopify metafields and metaobjects via the GraphQL Admin API. Use when adding custom fields to products/orders, creating custom content types, or building structured data models

by jeremylongshore(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from jeremylongshore/tons-of-skills-marketplace (plugins/saas-packs/shopify-pack/skills/shopify-metafields-metaobjects/SKILL.md). Install upstream with npx skills add jeremylongshore/tons-of-skills-marketplace --skill shopify-metafields-metaobjects. Copyright stays with the author (MIT).

Shopify Metafields & Metaobjects

Overview

Metafields attach key-value custom data to existing resources (products, variants, orders, customers). Metaobjects define entirely new content types with custom schemas. Together they replace the need for external databases for most custom data needs.

Prerequisites

  • Completed shopify-install-auth setup
  • Access scopes: read_metaobjects, write_metaobjects, read_metaobject_definitions, write_metaobject_definitions
  • Metafield scopes per resource: read_products/write_products for product metafields, etc.

Instructions

Step 1: Define a Metafield on Products

Use metafieldDefinitionCreate with namespace, key, type, and ownerType:

await client.request(METAFIELD_DEFINITION_CREATE, {
  variables: {
    definition: {
      namespace: "custom",
      key: "care_instructions",
      name: "Care Instructions",
      type: "multi_line_text_field",  // See references/metafield-types.md
      ownerType: "PRODUCT",
      pin: true, // Show in admin UI
    },
  },
});
// Always check userErrors — Shopify returns 200 even on validation failures

Step 2: Set Values in Batch with metafieldsSet

await client.request(METAFIELDS_SET, {
  variables: {
    metafields: [
      {
        ownerId: "gid://shopify/Product/123456",
        namespace: "custom",
        key: "care_instructions",
        value: "Machine wash cold.\nTumble dry low.",
        type: "multi_line_text_field",
      },
      // Up to 25 metafields per call
    ],
  },
});

Step 3: Create a Metaobject Definition

Define a custom content type (e.g., "Designer" with typed fields):

await client.request(METAOBJECT_DEFINITION_CREATE, {
  variables: {
    definition: {
      type: "$app:designer",
      displayNameKey: "name",
      fieldDefinitions: [
        { key: "name", name: "Name", type: "single_line_text_field" },
        { key: "bio", name: "Bio", type: "multi_line_text_field" },
        { key: "photo", name: "Photo", type: "file_reference" },
      ],
      access: { storefront: "PUBLIC_READ" },
    },
  },
});

Step 4: Create Metaobject Instances

await client.request(METAOBJECT_CREATE, {
  variables: {
    metaobject: {
      type: "$app:designer",
      handle: "jane-doe",
      fields: [
        { key: "name", value: "Jane Doe" },
        { key: "bio", value: "Award-winning textile designer." },
      ],
    },
  },
});

See metafield-types.md for all types, toml-config.md for app config, and bulk-metafield-ops.md for bulk operations.

Output

  • Metafield definitions registered on target resource types
  • Metafield values set on individual resources (batch supported, max 25 per call)
  • Custom metaobject types with typed field schemas
  • Metaobject instances queryable via Storefront and Admin APIs

Error Handling

Error Cause Solution
TAKEN Namespace + key already exists on this owner type Use metafieldDefinitionUpdate or choose a different key
INVALID_TYPE Type string not in Shopify's registry Check metafield-types.md
INVALID_VALUE Value doesn't match declared type Cast value to correct format before setting
TOO_LONG Value exceeds type limit (512KB for text types) Truncate or switch to multi_line_text_field

Examples

Adding Care Instructions to All Products

Define a "care_instructions" metafield on the PRODUCT owner type, then bulk-set values across hundreds of products in batches of 25.

See Bulk Metafield Ops for the batch set/delete operations.

Choosing the Right Metafield Type

You need to store a color swatch, a date range, or a product reference. Pick the correct type from Shopify's type registry.

See Metafield Types for the complete type list with value format examples.

Declaring Metafields in App Configuration

Define metafield and metaobject schemas in shopify.app.toml so they deploy automatically with the app instead of making API calls.

See TOML Config for the app configuration syntax.

Resources

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/jeremylongshore-tons-of-skills-marketplace-shopify-metaf-ac51de/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

jeremylongshore-tons-of-skills-marketplace-shopify-metaf-ac51de.ocm.jsonjson
{
  "ocm": "1",
  "id": "jeremylongshore-tons-of-skills-marketplace-shopify-metaf-ac51de",
  "kind": "skill",
  "name": "shopify-metafields-metaobjects",
  "description": "Model custom data with Shopify metafields and metaobjects via the GraphQL Admin API. Use when adding custom fields to products/orders, creating custom content types, or building structured data models beyond Shopify's default schema. Trigger with phrases like \"shopify metafields\", \"shopify metaobjects\", \"custom data shopify\", \"shopify custom fields\", \"metafield definition\".",
  "publisher": "jeremylongshore",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "saas",
      "ecommerce",
      "shopify",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Model custom data with Shopify metafields and metaobjects via the GraphQL Admin API. Use when adding custom fields to products/orders, creating custom content types, or building structured data models beyond Shopify's default schema. Trigger with phrases like \"shopify metafields\", \"shopify metaobjects\", \"custom data shopify\", \"shopify custom fields\", \"metafield definition\"."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/jeremylongshore/tons-of-skills-marketplace",
      "path": "plugins/saas-packs/shopify-pack/skills/shopify-metafields-metaobjects/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/jeremylongshore/tons-of-skills-marketplace/blob/HEAD/plugins/saas-packs/shopify-pack/skills/shopify-metafields-metaobjects/SKILL.md",
      "key": "jeremylongshore/tons-of-skills-marketplace/plugins/saas-packs/shopify-pack/skills/shopify-metafields-metaobjects/SKILL.md"
    },
    "compatibility": "Designed for Claude Code",
    "allowed_tools": [
      "Read,",
      "Write,",
      "Edit,",
      "Bash(npm:*),",
      "Grep"
    ],
    "license": "MIT"
  },
  "instructions": "# Shopify Metafields & Metaobjects\n\n## Overview\n\nMetafields attach key-value custom data to existing resources (products, variants, orders, customers). Metaobjects define entirely new content types with custom schemas. Together they replace the need for external databases for most custom data needs.\n\n## Prerequisites\n\n- Completed `shopify-install-auth` setup\n- Access scopes: `read_metaobjects`, `write_metaobjects`, `read_metaobject_definitions`, `write_metaobject_definitions`\n- Metafield scopes per resource: `read_products`/`write_products` for product metafields, etc.\n\n## Instructions\n\n### St",
  "cost": {
    "context_tokens": 1168
  }
}

Fetch it by URL: GET /api/v1/registry/jeremylongshore-tons-of-skills-marketplace-shopify-metaf-ac51de/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.