Cant use flutter DateTime in ferry query

228 Views Asked by At

Here is the query

query UpcomingPendingEvents($attendantId: ID, $eventDateTimeGt: DateTime) {
    attendances(attendant_Id: $attendantId, attending: "0",
        event_Datetime_Gt: $eventDateTimeGt, first: 10,) {
        # some fields here
    }
}

I get the error A value of type 'DateTime' can't be assigned to a variable of type 'GDateTimeBuilder?' when I use the following query

gqlClient.request(GUpcomingPendingEventsReq(
            (b) => b
            ..vars.attendantId = attendantId
            ..vars.eventDateTimeGt = DateTime.parse('2021-12-15T17:00:00'),
    ));

And when I try to use it like that.

gqlClient.request(GUpcomingPendingEventsReq(
            (b) => b
            ..vars.attendantId = attendantId
            ..vars.eventDateTimeGt = DateTime.parse('2021-12-15T17:00:00') as GDateTimeBuilder?,
    ));

I get runtime error type 'DateTime' is not a subtype of type 'GDateTimeBuilder?' in type cast.

1

There are 1 best solutions below

0
On

I think you need to assign it to the value on the GDateTimeBuilder.

 ...
 (b) => b
 ..vars.attendantId = attendantId
 ..vars.eventDateTimeGt.value = '2021-12-15T17:00:00' // <-- here
 ...