Loading...
Loading...
MUST be used first when prompts mention Metafields or Metaobjects. Use Metafields and Metaobjects to model and store custom data for your app. Metafields extend built-in Shopify data types like products or customers, Metaobjects are custom data types that can be used to store bespoke data structures. Metafield and Metaobject definitions provide a schema and configuration for values to follow.
npx skill4agent add shopify/shopify-ai-toolkit shopify-custom-databashbashnode scripts/search_docs.mjs "<operation or type name>"bashnode scripts/validate.mjs --code '...' --model YOUR_MODEL_NAME --client-name YOUR_CLIENT_NAME --client-version YOUR_CLIENT_VERSION --artifact-id YOUR_ARTIFACT_ID --revision REVISION_NUMBER# shopify.app.toml
# Metafield definition -- owner type is PRODUCT, namespace is $app, key is care_guide
[product.metafields.app.care_guide]
type = "single_line_text_field"
name = "Care Guide"
access.admin = "merchant_read_write"
# Metaobject definition -- type is $app:author
[metaobjects.app.author]
name = "Author"
display_name_field = "name"
access.storefront = "public_read"
[metaobjects.app.author.fields.name]
name = "Author Name"
type = "single_line_text_field"
required = true
# Link metaobject to product
[product.metafields.app.author]
type = "metaobject_reference<$app:author>"
name = "Book Author"access.admin = "merchant_read_write"metafieldDefinitionCreatemetaobjectDefinitionCreatemetafieldDefinitionCreatemetaobjectDefinitionCreate[metaobjects.app.example...]shopify.app.tomltype: $app:example[product.metafields.app.example]namespace: $appkey: examplenamespace: appmetafieldsSetnamespacemutation {
metafieldsSet(metafields:[{
ownerId: "gid://shopify/Product/1234",
key: "example",
value: "Hello, World!"
}]) { ... }
}metaobjectUpsertmutation {
metaobjectUpsert(handle: {
type: "$app:author",
handle: "my-metaobject",
}, metaobject: {
fields: [{
key: "example",
value: "Hello, world!"
}]
}) { ... }
}namespacejsonValue# Admin API
query {
product(id: "gid://shopify/Product/1234") {
example: metafield(key: "example") { jsonValue }
}
}
# Storefront API
query {
product(handle: "wireless-headphones-1") {
example: metafield(key: "example") { value }
}
}# Admin API
query {
metaobjects(type: "$app:author", first: 10) {
nodes {
handle
example: field(key:"example") { jsonValue }
}
}
}
# Storefront API
query {
metaobjects(type: "$app:author", first: 10) {
nodes {
handle
example: field(key:"example") { value }
}
}
}function Extension() {
// ESSENTIAL: Register this metafield in `shopify.extension.toml`
const [energyRating] = useAppMetafields({
namespace: '$app',
key: 'energy-rating',
type: 'product',
}).filter(
(entry) =>
entry.target.id === productVariantId,
);
}query Input {
cart {
lines {
merchandise {
__typename
... on ProductVariant {
example: metafield(namespace: "$app", key: "example") { jsonValue }
}
}
}
}
}shopify app initshopify app generate extensionshopify app devshopify app deployshopifynpm install -g @shopify/cli@latest
# or
yarn global add @shopify/cli@latest
# or
pnpm install -g @shopify/cli@latest
# or (macOS only)
brew tap shopify/shopify && brew install shopify-clishopify [topic] [command] [flags]--verbose--no-color--path <value>--resetexport SHOPIFY_HTTP_PROXY=http://proxy.com:8080
export SHOPIFY_HTTPS_PROXY=https://secure-proxy.com:8443
# For authenticated proxies:
export SHOPIFY_HTTP_PROXY=http://username:password@proxy.com:8080shopify upgradeshopify help [command]SHOPIFY_CLI_NO_ANALYTICS=1