Describe the bug
I expected that I'd be able to create metafields on collections and then access them via a custom Storefront API GraphQL query. Is this something I should be able to do? I created some collection metafields using a third party app and can access them via Shopify's GraphiQL app, but not via a custom Storefront API query.
To Reproduce
Steps to reproduce the behaviour:
{
shop {
collectionByHandle(handle: "my-products") {
id
title
metafields(first:7 ) {
edges {
node {
id
key
value
}
}
}
products(first:10) {
edges {
node {
id
title
collections(first: 10) {
edges {
node {
id
title
}
}
}
}
}
}
}
}
}
Error: No field of name "metafields" found on type "Collection" in schema:export const queryCollectionByHandle = (handle) => {
const query = ApiClient.getShopify().graphQLClient.query((root) => {
root.add('shop', shop => {
shop.add(
'collectionByHandle',
{ args: { handle } },
collection => {
collection.add('title')
collection.add('description')
collection.addConnection('metafields', { args: { first: 10 } },
field => {
field.add('key')
field.add('value')
})
...
Expected behavior
I expected the collection metafields to be returned as they are in the Shopify GraphiQL app.
Environment (please complete the following information):
Additional context
Add any other context about the problem here.
Bug Report Checklist
Hi @sheelah,
this repo uses Shopify storefront API, metafields only live on these types for the storefront.
Is it possible you added metafields in GraphiQL on an Admin API instead?
@StefanSlehta I see - thanks for the info! I had added the collection metafields via a third party app which must use the admin API & was expecting them to not show in the GraphiQL app either if they weren't supported in the Storefront API.
It is a real bummer that it is not possible to access metafields on Collection resource types via the Shopify storefront API.
Are there any plans for this functionality to be added or are there any sort of workarounds for accessing this information?