ChilliCream / ChilliCream/graphql-platform

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

Open
#5,256 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🌶️ strawberry shake
Dominant language
C#
Stars
5.8k
Forks
810
Avg merge
15h 39m
Merged PRs (30d)
98

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated IOperationResult.Build method and inspect how the response JSON for scopeVariants is converted into the .NET result object. Compare the generated mapping with the response shown in the report and verify that scope and name are populated for both list elements. Done means the reported Strawberry Shake query no longer produces null property values.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.