A property name formatter for GraphQL.Query.Builder based on Newtonsoft.Json.
$ dotnet add package GraphQL.Query.Builder.Formatter.NewtonsoftJson
A Newtonsoft.Json property name formatter for GraphQL.Query.Builder (>= 2.0.0).
This formatter returns the JsonPropertyAttribute value.
> dotnet add package GraphQL.Query.Builder.Formatter.NewtonsoftJson
public class Human
{
[JsonProperty("firstName")]
public string? FirstName { get; set; }
[JsonProperty("lastName")]
public string? LastName { get; set; }
}
// Initialize the options
QueryOptions options = new()
{
Formatter = SystemTextJsonPropertyNameFormatter.Format
};
// Create the query with the options
var query = new Query<Human>("humans", options)
.AddArguments(new { id = "uE78f5hq" })
.AddField(h => h.FirstName)
.AddField(h => h.LastName);
Console.WriteLine("{" + query.Build() + "}");
// Output:
// {humans(id:"uE78f5hq"){firstName lastName}