Zaid-Ajaj / Snowflaqe

A dotnet CLI to generate type-safe GraphQL clients for F# and Fable with automatic deserialization, static query verification and type checking
MIT License
157 stars 26 forks source link

Refactored fsproj generation to System.Xml.Linq and added using of StringBuffer for F# code generation #40

Closed anthony-mi closed 3 years ago

Zaid-Ajaj commented 3 years ago

Hi @anthony-mi any update on this PR?

anthony-mi commented 3 years ago

Not over this yet. Now I'm working on a different branch so that the user can specify in the config which serializer he uses, so that the GqlClient is generated for the user's serializer.

Zaid-Ajaj commented 3 years ago

Not over this yet. Now I'm working on a different branch so that the user can specify in the config which serializer he uses, so that the GqlClient is generated for the user's serializer.

You mean issue #36? Note that there is still discussion there isn't sorted out about supporting discriminator-based deserialization which STJ doesn't support by default. This is required when deserializing GraphQL unions and interfaces.

for example this type

type User = { Id: int; Username: string }
type Bot = { Identifier: string }
type Actor =
    | User of User
    | Bot of Bot

should be deserializable from the JSON

[
      {
          "__typename": "User",
          "Id": 42,
          "Username": "John"
      },
      {
           "__typename": "Bot",
            "Identifier": "Sentient Bot"
      }
]

The following fails

open System.Text.Json
open System.Text.Json.Serialization

let options = JsonSerializerOptions()
options.Converters.Add(JsonFSharpConverter())
JsonSerializer.Deserialize<Actor list>(json, options)

Whereas it works perfectly when using Fable.Remoting.Json

There is more work than just switching the serialization library so please check to see for the correctness of the approach. You can open a draft if you want to share your WIP

Zaid-Ajaj commented 3 years ago

Hi there @anthony-mi I see that you rebased to latest changes in the master branch. Do you plan on implementing the requested changes or should I just merge and do them myself?

xperiandri commented 3 years ago

@Zaid-Ajaj I think you can do that yourself. As they are quite small

Zaid-Ajaj commented 3 years ago

Merged and fixed the issues myself.

Please note that this is not an ideal process for me as a maintainer because I already spent time reviewing the PR and answered follow up questions so that contributors are able to finish the PR and alleviate the overall workload