Skip to content

How to make StrawberryShake working with JSON scalar type #5465

Answered by antyrama
antyrama asked this question in Q&A
Discussion options

You must be logged in to vote

It's solved now.

  • You don't need to implement any additional serializer, it's already there StrawberryShake.Serialization.JsonSerializer, this thread helped #3543

  • You have to add below to your schema.extensions.graphql file

     extend scalar JSON
       @serializationType(name: "global::System.Text.Json.JsonElement")
       @runtimeType(name: "global::System.Text.Json.JsonDocument")
    
  • You have to register in IoC the above serializer with name of your custom scalar services.AddSerializer(new JsonSerializer("JSON"));

This is it and that's it!
I whish I could read the above in documentation 3 days ago, instead of pulling my hair and reverse engineer code ¯_(ツ)_/¯

Cheers
P

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by benmccallum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant