Skip to content

Remove default JsonSerializer and require explicit configuration #188

@joerneu

Description

@joerneu

This line always overwrites Option.JsonSerializer:

Options.JsonSerializer = serializer ?? throw new ArgumentNullException(nameof(serializer));

Therefore the following code does not work as expected:

_client = new GraphQLHttpClient(o =>
{
    o.EndPoint = new Uri(_testUrl);
    o.JsonSerializer = new SystemTextJsonSerializer(
        options =>
        {
            options.Converters.Add(new JsonStringEnumConverter());
        });
});

The constructor above calls the constructor

public GraphQLHttpClient(GraphQLHttpClientOptions options, HttpClient httpClient) : this(options, httpClient, new NewtonsoftJsonSerializer()) { }

which sets the JsonSerializer always to NewtonsoftJsonSerializer.

By the way, I think it would be better to make a breaking change, remove the reference to GraphQL.Client.Serializer.Newtonsoft and require the caller to provide the serializer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions