A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I am trying this query on the Admin API (2023-01)
{ product(id: "gid://shopify/Product/7677457531050") { id handle title metafield(namespace: "tech_drawings", key: "cad3d") { namespace key type references(first:10) { nodes { __typename ... on MediaImage { id image { url } } ... on GenericFile { id url } } } } } }
but I am not getting the results I expect.
product.metafields.tech_drawings.cad3d is a list of files. The product has 4 attachments in the metafield, 2 are of type GenericFile and 2 are MediaImage. I can only get back one file type, the files of the other type are null.
The type I get back is always whatever type is first in the list.
For example, if the attached files are in the order
the result of the query is:
{
"data": {
"product": {
"id": "gid:\/\/shopify\/Product\/7677457531050",
"handle": "productbuilder",
"title": "ProductBuilder",
"metafield": {
"namespace": "tech_drawings",
"key": "cad3d",
"type": "list.file_reference",
"references": {
"nodes": [
{
"__typename": "MediaImage",
"id": "gid:\/\/shopify\/MediaImage\/28522171531434",
"image": {
"url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0600\/8383\/0954\/files\/PrintButtonDisabled.png?v=1678460680"
}
},
null,
null,
{
"__typename": "MediaImage",
"id": "gid:\/\/shopify\/MediaImage\/28540311929002",
"image": {
"url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0600\/8383\/0954\/files\/tinyimg.png?v=1678798239"
}
}
]
}
}
}
},
"extensions": {
"cost": {
"requestedQueryCost": 24,
"actualQueryCost": 7,
"throttleStatus": {
"maximumAvailable": 1000.0,
"currentlyAvailable": 993,
"restoreRate": 50.0
}
}
}
}
If I change the order of the files to
I get this:
{
"data": {
"product": {
"id": "gid:\/\/shopify\/Product\/7677457531050",
"handle": "productbuilder",
"title": "ProductBuilder",
"metafield": {
"namespace": "tech_drawings",
"key": "cad3d",
"type": "list.file_reference",
"references": {
"nodes": [
{
"__typename": "GenericFile",
"id": "gid:\/\/shopify\/GenericFile\/28540547104938",
"url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0600\/8383\/0954\/files\/thisIsACADfile.txt?v=1678800901"
},
null,
{
"__typename": "GenericFile",
"id": "gid:\/\/shopify\/GenericFile\/28540311961770",
"url": "https:\/\/cdn.shopify.com\/s\/files\/1\/0600\/8383\/0954\/files\/tinyimg.doilooklikeiknowwhatapngis?v=1678798239"
},
null
]
}
}
}
},
"extensions": {
"cost": {
"requestedQueryCost": 24,
"actualQueryCost": 5,
"throttleStatus": {
"maximumAvailable": 1000.0,
"currentlyAvailable": 995,
"restoreRate": 50.0
}
}
}
}
I do get the expected results (all 4 attachments appear correctly) using the Shopify GraphiQL app Storefront API. Is there a way to get the same result with the Admin API?
Solved! Go to the solution
This is an accepted solution.
@IHaveNoAnswers, bug fixed! Thanks for letting us know.
To learn more visit the Shopify Help Center or the Community Blog.
Hi @IHaveNoAnswers – it looks like you've found a bug here. I've asked the team to investigate, and we'll follow up here when a fix has rolled out.
To learn more visit the Shopify Help Center or the Community Blog.
This is an accepted solution.
@IHaveNoAnswers, bug fixed! Thanks for letting us know.
To learn more visit the Shopify Help Center or the Community Blog.