chkimes / graphql-net

Convert GraphQL to IQueryable
MIT License
891 stars 86 forks source link

Unsupported CLR with nullable DataTime #86

Open MostafaEsmaeili opened 6 years ago

MostafaEsmaeili commented 6 years ago

Hi pals, I have a class of "Person" in which there is a field named "BirthDate" (public DateTime? BirthDate) and it is nullable. When the GraphQL is going to execute the query, I receive the following error message:

Unsupported CLR type ``DateTime''

Could you please help me with the issue?

Yours Sincerely

einer20 commented 6 years ago

in the readme file, the developer cleary said that DateTime type is not yet supported.

mstephano commented 6 years ago

Any news on the fix for DateTime please? I really like this library, so much easier to learn and use than the other one.

JimmyAtSchotte commented 6 years ago

I got rid of the "Unsupported CLR type ``DateTime''" message by adding this scalar to the scheme

schema.AddScalar(new { year = 0, month = 0, day = 0 }, ymd => new DateTime(ymd.year, ymd.month, ymd.day));

mstephano commented 6 years ago

Thank you very much Jimmy, I have tested by adding your code and I can finally use schema.AddType<MyObject>().AddAllFields() on all of my entities!!

This is a great day!!!!!!