You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was using the ProductSet mutation with the method that automatically deserializes the result, but at one moment is stopped deserializing and I am not sure why.
How I am using it?
This is an extract of what I was doing:
internalrecordProductSetResult{[JsonPropertyName("productSet")]internalrequiredProductSetPayloadProductSet{get;set;}}
.../// Then bellow in my code
...var graphRequest =newGraphRequest(){Query=""" mutation upsertProduct($productSet: ProductSetInput!, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $productSet) { product { id handle createdAt publishedAt variants(first: 50) { nodes { id selectedOptions { name value } } } } userErrors { field message code } } } """,Variables=newDictionary<string,object>{// Here my variable properties, but this is not the issue so I will not waste space with this}};varresult=awaitgraphService.PostAsync<ProductSetResult>(graphRequest);
The deserialization does not occur, I have no error but the result.Data.ProductSet is always null.
I ended up doing the deserialization myself, and I have no issues doing this without problem (I try catch user and query errors and have none in both cases)
usingvarresult=awaitgraphService.PostAsync(graphRequest);varrawJsonObject=result.Json.GetRawObject();if(rawJsonObjectis not JsonElementjsonElement)thrownewException("Unexpected json object type "+rawJsonObject.GetType().FullName);if(jsonElement.GetProperty("data").GetProperty("productSet").ValueKind==JsonValueKind.Undefined||jsonElement.GetProperty("data").GetProperty("productSet").ValueKind==JsonValueKind.Null)thrownewException("Json value is not defined or null for the product");returnnewProductSetResult(){ProductSet=newProductSetPayload(){product=newShopifySharp.GraphQL.Product(){id=jsonElement.GetProperty("data").GetProperty("productSet").GetProperty("product").GetProperty("id").GetString(),handle=jsonElement.GetProperty("data").GetProperty("productSet").GetProperty("product").GetProperty("handle").GetString(),createdAt=jsonElement.GetProperty("data").GetProperty("productSet").GetProperty("product").GetProperty("createdAt").GetDateTime(),variants=newProductVariantConnection(){nodes=[.. jsonElement.GetProperty("data").GetProperty("productSet").GetProperty("product").GetProperty("variants").GetProperty("nodes").EnumerateArray().Select(variantNode =>newShopifySharp.GraphQL.ProductVariant(){id=variantNode.GetProperty("id").GetString(),selectedOptions=[.. variantNode.GetProperty("selectedOptions").EnumerateArray().Select(optionNode =>newSelectedOption(){name=optionNode.GetProperty("name").GetString(),value=optionNode.GetProperty("value").GetString()})]})]}}}};
For now is not urgent, but I would like to understand why in some cases it should work the automatic deserialization and other no (I used with other queries and mutations without problem i.e. CreateMetafieldDefinition)
The text was updated successfully, but these errors were encountered:
Hello,
I was using the ProductSet mutation with the method that automatically deserializes the result, but at one moment is stopped deserializing and I am not sure why.
How I am using it?
This is an extract of what I was doing:
The deserialization does not occur, I have no error but the
result.Data.ProductSet
is always null.I ended up doing the deserialization myself, and I have no issues doing this without problem (I try catch user and query errors and have none in both cases)
For now is not urgent, but I would like to understand why in some cases it should work the automatic deserialization and other no (I used with other queries and mutations without problem i.e. CreateMetafieldDefinition)
The text was updated successfully, but these errors were encountered: