ChilliCream / ChilliCream/graphql-platform

Example serializer from the Strawberry Shake documentation doesn't work

Open
#7,575 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Product

Strawberry Shake

Version

13.9.14

Link to minimal reproduction

https://filebin.net/gs6gkxscspus013d/GraphQlSerializerIssue.zip

Steps to reproduce
  1. Go to https://chillicream.com/docs/strawberryshake/v13/scalars#any-or-json
  2. Copy the example serializer:
public class MyJsonSerializer : ScalarSerializer<JsonElement, object>
{
    public MyJsonSerializer(string typeName = BuiltInScalarNames.Any)
        : base(typeName)
    {
    }
    public override object Parse(JsonElement serializedValue)
    {
        // handle the serialization of the JsonElement
    }
    protected override JsonElement Format(object runtimeValue)
    {
        // handle the serialization of the runtime representation in case
        // the scalar is used as a variable.
    }
}
  1. Paste in a new class
  2. You'll get an error on protected override JsonElement Format(object runtimeValue)
  3. It is impossible to implement this method; it gives compiler error CS0462 since it tries to override two methods:
    protected abstract TSerialized Format(TRuntime runtimeValue);
    public object? Format(object? runtimeValue)
What is expected?

A working example

What is actually happening?

Compiler error

Relevant log output

No response

Additional context

No response

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 Strawberry Shake v13 “Any or JSON” documentation page and the linked minimal reproduction, then inspect the shown ScalarSerializer example and its compiler error. Confirm the documented serializer example compiles without CS0462 and that the corrected example still demonstrates the intended serialization behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, graphql
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.