Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi all! I have a custom Storefront in Hydrogen, deployed in Oxygen.
I created a Merchant Metaobject in my shop to store some merchant data. Then I reference these Metaobjects in various Products, based on who merchandises those products.
✅ WORKING AS EXPECTED: From the Product Entity in GraphQL, I can reference the Metaobject correctly and display the merchant data in the Product Details Page or Product Card.
❌ NOT WORKING AS EXPECTED: I have also created a Merchant page, and from the Metaobject in GraphQL I can query all the fields, BUT I can't query the referencedBy connection, where I want to query all the Products where this Metaobject is referenced at.
How can I get this kind of information in the Metaobject payload?
Thank you! 😁
Hi,
I have the same issue. Can you show us some samples on how to query the reference products?
I have this query but it is not working.
{
metaobjects(type: "test", first: 2) {
nodes {
id
displayName
referencedBy(first: 2) {
edges {
node {
name
namespace
target {
... on Product {
id
}
}
}
}
}
}
}
This is the message response.
Internal error. Looks like something went wrong on our end.
I think I am using a wrong field. This query is working for me. Hope this helps.
{
metaobjects(type: "test", first: 25) {
nodes {
id
displayName
referencedBy(first: 25) {
edges {
node {
referencer {
... on Product {
id
title
featuredImage {
url(transform:{maxWidth:100})
}
}
}
}
}
}
}
}
}
Im having the same issue, but I cant use the "referencedBy" syntax. I can read about it in the docs. Do i need to change my access scope for hydrogen or something? Thanks
Where did you see it in the docs ? I just find it for Admin API here only:
https://shopify.dev/docs/api/admin-graphql/2024-07/objects/Metaobject#connection-referencedby
I guess there is no way how to do that with storefront, or might I be wrong?
Are you really using the storefront? Is this not Admin API?