Releases: byme8/ZeroQL
Releases · byme8/ZeroQL
v3.2.0-preview.3
Add unexpected error reporting.
v3.2.0-preview.2
Add initial cancelation support.
v3.2.0-preview.1
Add initial support for unions and "... on" syntax.
v3.1.0
v3.1.0-preview.1
Add initial support for Graphql interfaces.
v3.0.0
v3.0.0-preview1
Attempt to fix CLI build.
v2.1.1
v2.1.0
Adds support for user-defined scalars.
Let's suppose that server returns the Instant
type from NodaTime
.
The schema looks like that
"""
Represents an instant on the global timeline, with nanosecond resolution.
"""
scalar Instant
type Query {
instant: Instant!
}
The ZeroQL knows nothing about the scalar type Instant
, but we should be able to add support for it. To make it work, create the class Instant
in the ZeroQL namespace and define a JSON serializer for it:
namespace ZeroQL;
public class Instant
{
public DateTimeOffset DateTimeOffset { get; set; }
}
public class InstantJsonConverter : JsonConverter<Instant?>
{
public override Instant? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var text = reader.GetString();
if (string.IsNullOrEmpty(text))
{
return null;
}
return new Instant { DateTimeOffset = DateTimeOffset.Parse(text) };
}
public override void Write(Utf8JsonWriter writer, Instant? value, JsonSerializerOptions options)
{
var text = value?.DateTimeOffset.ToString("O");
writer.WriteStringValue(text);
}
}
Then, somewhere in your app, add this serializer to JSON options:
ZeroQLJsonOptions.Configure(o => o.Converters.Add(new InstantJsonConverter()));
Now we are ready to consume it:
var response = await qlClient.Query(static q => q.Instant);