Closed AnandPrabha closed 6 months ago
Thanks for the report @AnandPrabha! Could you show me the code you're using to send the Graph query?
This is expected, although we should document it. Because Media is an interface, you must include the typename field so that the serializer knows which type to deserialize to. Note that the typename field must be the FIRST field in the object.
The query below should work.
{ products(first: 1) { nodes { id title media(first: 1) { nodes { alt id mediaContentType preview { image { __typename id url } } } } } } }
The suggested code didn't work initially. However, after trying to add typename to the media nodes, the issue was resolved. Here's the updated and working structure:
{
products(first: 1)
{
nodes
{
id
title
media(first: 1)
{
nodes
{
**typename**
alt
id
mediaContentType
preview
{
image
{
id
url
}
}
}
}
}
}
}
Ah yes, I had it at the wrong place.
Hello,
I've encountered an issue with ShopifySharp version 6.13.0 when trying to query products along with their media information. Specifically, the problem arises when I execute a GraphQL query to fetch products and their associated media. Here is the query I am using: { products(first: 1) { nodes { id title media(first: 1) { nodes { alt id mediaContentType preview { image { id url } } } } } } } Upon executing this query, I receive the following exception: One or more errors occurred. (Deserialization of interface types is not supported. Type 'ShopifySharp.GraphQL.IMedia'. Path: $.nodes[0].media.nodes[0] | LineNumber: 0 | BytePositionInLine: 36.) seems that the library struggles to handle the deserialization of interface types correctly, particularly when fetching media nodes associated with products. I would appreciate any guidance on how to resolve this issue or if there are any workarounds available