Open mike-a-stephens opened 1 month ago
To deserialize automatically, try using the generic overload SendAsync<ProductCreatePayload>
.
Referring to my original report (near the bottom), you will see that I originally tried the generic method you mentioned. It was the exception being thrown from this generic method which lead lead me to investigating the issue further. As mentioned, out of the box using the automatic deserialization fails with the exception I posted.
Further to this, it appears that I am only having issues with SendAsync<ProductCreatePayload>()
. I just created another API call using SendAsync<ProductVariantsBulkCreatePayload>()
and that deserializes correctly and without an exception being thrown.
Thanks for the detailed investigation so far @mike-a-stephens. I'm going to be working on the GraphService in the next day or so, especially picking up an old PR I never finished in #1051. I will be sure to get this fixed and add test cases for this deserialization issue.
When deserializing the response from a GraphQL mutation, System.Text.Json.JsonSerializer is throwing an exception, whereas NetwtonSoft can deserialize the response successfully.
For example, using the following code:
The NewtonSoft deserializer succeeds and returns the deserialized object, however System.Text.Json deserializer fails with the following exception:
This appears to be causing the generic ShopifySharp SendAsync methods to fail when processing the response of a mutation.
For example, in my original attempt at implementing the productCreate call, I used code similar to the following:
but was getting the exception thrown above, which lead me to try deserializing manually with NewtonSoft.
Am I doing something wrong, or is there indeed an issue when using System.Text.Json.JsonSerializer.Deserialize<>() ?