metafieldStorefrontVisibility
Deprecated. This query will be removed in a future version. Use the `access.storefront` field inside the `metafieldDefinition` query instead.
Returns a record by ID. A
record lists the
metafields to make visible in the Storefront API.
Anchor to Possible returnsPossible returns
- Anchor to MetafieldStorefrontVisibilityMetafield•
Storefront Visibility By default, the Storefront API can't read metafields. To make specific metafields visible in the Storefront API, you need to create a
record. A
record is a list of the metafields, defined by the
,
namespace
, andkey
, to make visible in the Storefront API.Learn about [exposing metafields in the Storefront API] (https://shopify.dev/custom-storefronts/products-collections/metafields) for more details.
- created
At •Datenon-nullTime! The date and time when the metafield was set to visible in the Storefront API.
- id•ID!non-null
A globally-unique ID.
- key•String!non-null
The key of a metafield to make visible in the Storefront API.
- legacy
Resource •Id Unsignednon-nullInt64! The ID of the corresponding resource in the REST Admin API.
- namespace•String!non-null
The namespace of a metafield to make visible in the Storefront API.
- owner
Type •Metafieldnon-nullOwner Type! The owner type of a metafield to make visible in the Storefront API.
- updated
At •Datenon-nullTime! The date and time when the
record was updated.
- created
Retrieve a MetafieldStorefrontVisibility record
query MetafieldStorefrontVisibility($id: ID!) {
metafieldStorefrontVisibility(id: $id) {
namespace
key
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query MetafieldStorefrontVisibility($id: ID!) { metafieldStorefrontVisibility(id: $id) { namespace key } }",
"variables": {
"id": "gid://shopify/MetafieldStorefrontVisibility/1027955819"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query MetafieldStorefrontVisibility($id: ID!) {
metafieldStorefrontVisibility(id: $id) {
namespace
key
}
}`,
{
variables: {
"id": "gid://shopify/MetafieldStorefrontVisibility/1027955819"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query MetafieldStorefrontVisibility($id: ID!) {
metafieldStorefrontVisibility(id: $id) {
namespace
key
}
}`,
"variables": {
"id": "gid://shopify/MetafieldStorefrontVisibility/1027955819"
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query MetafieldStorefrontVisibility($id: ID!) {
metafieldStorefrontVisibility(id: $id) {
namespace
key
}
}
QUERY
variables = {
"id": "gid://shopify/MetafieldStorefrontVisibility/1027955819"
}
response = client.query(query: query, variables: variables)