How do I get a Hasura/Strawberry Shake project to build when query has Date and date types?

27 Views Asked by At

We have a query that accepts two arguments, one of type Date and one of type date--something like this:

query TestQ($deadline: date!, $another_deadline: Date!) { ... }

When I attempt to build the project containing this query, it fails on an "already contains a definition for" exception because the autogenerated HasuraClient.Client class contains duplicate fields (I'm guessing one for each of the date parameters above):

    private readonly global::StrawberryShake.Serialization.IInputValueFormatter _dateFormatter;
    private readonly global::StrawberryShake.Serialization.IInputValueFormatter _dateFormatter;


// and in constructor:
      _dateFormatter = serializerResolver.GetInputValueFormatter("date");
      _dateFormatter = serializerResolver.GetInputValueFormatter("Date");

I also see:

private readonly global::StrawberryShake.Serialization.ILeafValueParser<global::System.String, global::System.DateTime> _dateParser;
 private readonly global::StrawberryShake.Serialization.ILeafValueParser<global::System.String, global::System.String> _stringParser;

//and in the constructor:
 _dateParser = serializerResolver.GetLeafValueParser<global::System.String, global::System.String>("date") ?? throw new global::System.ArgumentException("No serializer for type `date` found.");
 _dateParser = serializerResolver.GetLeafValueParser<global::System.String, global::System.DateTime>("Date") ?? throw new global::System.ArgumentException("No serializer for type `Date` found.");

I've tried adding various custom serializers by inheriting from StrawberryShake.Serialization.ScalarSerializer, including:

public class DbDateSerializer : ScalarSerializer<string , DateTime>

and following the instructions on the ChilliCream site, but nothing is working.

Does anyone have any suggestions on how I should proceed?

0

There are 0 best solutions below