I have products set up with metafield definitions with various namespaces, I was wondering if there is an easy way to get all 250 metafields with definitions in one query:
when I look at arguments for metafields: MetafieldConnection!, it doesn’t allow filtering by metafields with definitions only and it only allows filter by one namespace and a list of keys rather than multiple namespaces from all definitions that I know in one query.
What does the … on Product do, does it exclude the metafields w/o definitions?
Anyways I ended up doing this instead because I needed to filter out shopify standard metafields from metafield definitions and only grab the custom metafields for my use case by looping through all definitions, which could be more than 250 because the standard definitions are also returned in addition to the 250 custom ones I created:
query {
metafieldDefinitions(first: 250, ownerType: PRODUCT) {
edges {
node {
id
namespace
key
type {
name
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
and for each metafield definition, I only select those with namespaces belonging to custom metafields I created and run another query for each definition to get the actual values: