Skip to content

Strawberry Shake: fails to map properties from GraphQL response to .NET result object, resulting in .NET null values #5256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
ronnieholm opened this issue Jul 27, 2022 · 6 comments

Comments

@ronnieholm
Copy link

ronnieholm commented Jul 27, 2022

Is there an existing issue for this?

  • 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

  1. See description above.

Relevant log output

See description above.

Additional Context?

No response

Product

Strawberry Shake

Version

12.11.1

@YashanFernando
Copy link

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, the noStore option must be set to false
  • 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 id field.

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 !

@YashanFernando
Copy link

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.

@haohanyang
Copy link

@YashanFernando Have the same problem. Do you have any update on how to disable the client store on StrawberryShake.Blazor?

@YashanFernando
Copy link

@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.

@dhoffman432
Copy link

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.

@meilleur102
Copy link

meilleur102 commented May 9, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants