metaobject(handle: {
handle: "dacia",
type: "car-manufacturer"
}) {
fields {
references(first: 250) {
nodes {
__typename
... on Metaobject {
fields {
value
}
}
}
}
}
}
This is my code.
As you probably now you can reference another metaobject from a metaobject field.
What I want to do is fetch all metaobject field references from a metaobject.
As this might be hard to understand:
I have some car manufacturer meta objects: Ford, Audi, Mercedes.
I also have some model meta objects: Audi A1, Ford MK3, Mercedes A-Class
Audi A1 references Audi in one metaobject field and so on…
Now I want to fetch all model metaobjects for e.g. Mercedes (Mercedes A-Class and so on…).
However, this seems impossible to me with the GraphQL API!
https://shopify.dev/docs/api/storefront/2023-01/objects/Metaobject
Inside the documentation of the Metaobject it reads that you cannot load references of MetaObjects.
In the Shopify Admin area however you can see up to ten references for each metaobject. Why isn’t this part of the API? Are there workarounds?
Right now the only possible option seems to be to fetch all metaobjects and save them for a limited time on my PHP server to a MySQL database (where I can filter the data properly) and send only the required data as a reply to AJAX requests. But this is actually truly elaborate, I kinda expect the Shopify APIs to be able to deliver those data out of the box. What’s your thoughts on this?