Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
We have a graphql that gets a list of products and collections from the shopfiy products and collections.
We have custom data set up, the metafields we have are not defined but they have a namespace and key.
When i go check the ‘access on storefront’ it requires the name and description to be filled, I'm not able to select product only text, number or decimal.
I’ve attached our query and what we are getting back
export const GET_PRODUCTS_FOR_COLLECTION_IDS = gq1*
shopity
query GetProductsForCollections($ids: [ID! ]!) {
nodes (ids: $ids) {
on Collection {
products(first: 25) {
edges {
node {
title description
images (first: 2) {
edges {
node {
src
}
metafields(identifiers: [
{namespace: "custom", key: "test"),
]) {
id value
}
variants(first: 1) {
edges {
node {
id price
}
}
}
Response
description:
"A 12" by 8" portrait. No mount included. test'
J
images: Array (1), metafields: Array (1), ...]
description: "A 12\" by 8\" portrait. No mount included. tes
• images: Array (1)
Do: {_ typename:'Image', sre: 'https://cdn.shopify.com/s/f
length: 1
- [ [Prototype]]: Array(0)
- metafields: Array (1)
0: null length: 1
• [ [Prototype]]: Array (0)
title: "12\"×8\" Portrait (no mount)" ~ variants: Array (1)
- 0:
id: "gid://shopify/ProductVariant/39845834096810" price: "8.75"
_typename: "ProductVariant"- [ [Prototype]]: Object length: 1
- [ [Prototype]]: Array (0)
typename: "Product"- [[Prototype]]: Object
- constructor: f Object ()
- hasOwnProperty: f hasOwnProperty ()
- isPrototypeOf: f isPrototypeof()
- propertyIsEnumerable: f propertyIsEnumerable()
- toLocaleString: f toLocaleString ()
- toString: f toString()
- valuedf: f valuedf()
defineGetterf
_defineGetter_
_ ( )
Hi KrisAP, I think this issue is happening because a name and description must be provided when defining your metafield. These fields can't be left empty and it's a Shopify requirement. Can you add these in and try again?
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi Liam!
Thank you for your reply.
We have tried adding this but we are unable to change them to product. Our only options are text, decimal or numeric, we only have the option of selecting a product if we create a new metafield.
We are trying to get all of the products we have on the store via the graphql query.
Our graphql endpoint was the 2021 version. When I look at the shopify graphql api online it says that metafields for pagination is no longer supported. I believe this is what we were using. The other day our code crashed and now we have to use metafields with identifiers and namespaces. But we cannot do this as we need to get all metafields for multiple products in a single query. We can’t hardcode each namespace in as we need all of them, not just a single one. On the api for graphql the only supported queries for metafields are those with namespaces and identifiers.
Apologies we’re using the storefront api, not graphql api.