Strawberry Shake: fails to map properties from GraphQL response to .NET result object, resulting in .NET null values
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
In the Apollo Server sandbox environment, when I run the following query:
query Test {
attribute(id: "A1002_338465", scope: "en-GB") {
id
scopeVariants(scopeFilter: {scopeIDs: ["en-GB", "da-DK"]}) {
scope
name
}
}
}
the output is:
{
"data": {
"attribute": {
"id": "A1002_338465",
"scopeVariants": [
{
"scope": "en-GB",
"name": "Tailpiece size [mm]"
},
{
"scope": "da-DK",
"name": "Nippel dimension [mm]"
}
]
}
}
}
Running the same query with StrawberryShake, in the result scopeVariants has become a two elements list, but with scope and name properties being null.
I've verified that StrawberryShake is indeed getting scope and name back from the GraphQL server. Placing a breakpoint in the generated code:
public global::StrawberryShake.IOperationResult<ITestResult> Build(global::StrawberryShake.Response<global::System.Text.Json.JsonDocument> response)
{
...
}
response has the following value:
{
"data": {
"attribute": {
"__typename": "Attribute",
"id": "A1002_338465",
"scopeVariants": [
{
"__typename": "Attribute",
"scope": "en-GB",
"name": "Tailpiece size [mm]",
"id": "A1002_338465"
},
{
"__typename": "Attribute",
"scope": "da-DK",
"name": "Nippel dimension [mm]",
"id": "A1002_338465"
}
]
}
}
}
But for some reason, the values of scope and name aren't mapped onto the result.
Am I missing a setting somewhere or is this a bug with Strawberry?
I do wonder, though, why the Strawberry result has a different shape than that returned by Apollo Server sandbox environment.
Steps to reproduce
- See description above.
Relevant log output
See description above.
Additional Context?
No response
Product
Strawberry Shake
Version
12.11.1
Thank you for raising this @ronnieholm . I'm running into the same bug.
There seems to be a few conditions required to reproduce it.
- In
.graphqlrc.json, thenoStoreoption must be set tofalse - The nested object type must be the same as the parent (although it doesn't have to be the immediate child)
- The parent object must contain an
idfield.
It feels like what it's doing is, it's caching the shape of the parent object and deserializing the children into the same shape, ignoring any extra fields present in the children. If we add the extra two fields to be returned with the parent, those values will be included with the children as well.
I managed to create a minimal application that reproduces the issue here using HotChcolate and StrawberryShake using StrawberryShake12.14.0. Where,
- The server returns the correct values
- The queried object structure is similar to what's above
- And the child object returned from StrawberryShake contains null fields.
Hope this helps. Thank you for the wonderful work all !
Just a quick update in-case anyone else runs into this.
I can still replicate this with StrawberryShake.Blazor 13.0.5. Setting the noStore option in the .graphqlrc.json doesn't seem to disable the client store anymore.
Using the StrawberryShake.Server package works around this since the store is disabled by default.
@YashanFernando Have the same problem. Do you have any update on how to disable the client store on StrawberryShake.Blazor?
@haohanyang No.. Sorry. I had a bit of a dig through the configuration code but I couldn't figure out a way to disable it. I've just been using StrawberryShake.Server for my work.
Any update to this? I had this issue in .Net where my generated file is throwing an error at MapEntityNonNullableArray. Banana Cake Pop receives the correct data from the server but the value provided to my client fails to map datetimes on my entity.
I have the same issues with V15 Is there any progress on this? It make it so I can't use Strawberryshake for the subscription so I have to implement another way just for the sub.