Skip to content
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

Update C#-Operations Docs #98

Open
maaft opened this issue Dec 11, 2020 · 1 comment
Open

Update C#-Operations Docs #98

maaft opened this issue Dec 11, 2020 · 1 comment

Comments

@maaft
Copy link

maaft commented Dec 11, 2020

Currently Enums are not properly serialized when the standard Newtonsoft Serializer is used.

Solution:

public sealed class GraphQLEnumConverter : StringEnumConverter
  {
    public GraphQLEnumConverter()
        : base(new PascalCaseNamingStrategy())
    {
    }
  }

  internal sealed class PascalCaseNamingStrategy : NamingStrategy
  {
    protected override string ResolvePropertyName(string name) => name;
  }

GQLClient = new GraphQLHttpClient(new GraphQLHttpClientOptions
      {
        EndPoint = new Uri(EndpointHttp)

      }, new NewtonsoftJsonSerializer(new JsonSerializerSettings
      {
        Converters = new List<JsonConverter>{
              new StringEnumConverter(new PascalCaseNamingStrategy())
          }
      }));

This should be added to the docs.

@ardatan
Copy link
Collaborator

ardatan commented Dec 11, 2020

@maaft Could you create a PR that adds this to the docs?

@dotansimha dotansimha transferred this issue from dotansimha/graphql-code-generator Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants