dart-backend / belatuk-examples

A collection of example projects running on Angel3
BSD 3-Clause "New" or "Revised" License
5 stars 5 forks source link

DateTime issue with graphql example #3

Open jocubeit opened 1 year ago

jocubeit commented 1 year ago

I get the following error when trying to query humans in the starwars example using graphiql:

[SEVERE] startwars: {errors: [{message: Value of field "created_at" must be DateTime, got 2023-03-02T17:06:46.213487 (String) instead.}]}

{errors: [{message: Value of field "created_at" must be DateTime, got 2023-03-02T17:06:46.213487 (String) instead.}]}
package:graphql_server2/graphql_server2.dart 672:9   GraphQL.completeValue
package:graphql_server2/graphql_server2.dart 504:12  GraphQL.executeField
package:graphql_server2/graphql_server2.dart 471:46  GraphQL.executeSelectionSet
package:graphql_server2/graphql_server2.dart 688:14  GraphQL.completeValue
package:graphql_server2/graphql_server2.dart 629:29  GraphQL.completeValue
jocubeit commented 1 year ago

DateTime fields seem to be broken, both nullable and non-nullable. Pretty much means we can't use the graphQLDate type.

jocubeit commented 1 year ago

The issue appears to be the serialization of the date in the MapService. Specifically the following line:

https://github.com/dukefirehawk/angel/blob/9b85007072fdcd19bd79237ba2e3bf4e23c8021f/packages/framework/lib/src/core/map_service.dart#L87

If you amend the line to remove the serialization to an ISO 8601 string, then everything works as it should:

var now = DateTime.now(); //.toIso8601String();

Similarly the following lines would also need amending.

in the modify method: https://github.com/dukefirehawk/angel/blob/9b85007072fdcd19bd79237ba2e3bf4e23c8021f/packages/framework/lib/src/core/map_service.dart#L117

and in the update method: https://github.com/dukefirehawk/angel/blob/9b85007072fdcd19bd79237ba2e3bf4e23c8021f/packages/framework/lib/src/core/map_service.dart#L146

I suspect the issue is the serialization is attempted twice, once the by the MapService and then my the type converter later.

I'm happy to push a merge request if you like.

jocubeit commented 1 year ago

Actually I'm having other issues now, as soon as I query nested objects. I'll investigate further and get back to this issue.