0

I am using Hot Chocolate graphQL with .NET. In my Dto, I have one DatetimeOffset field but when I see the schema on UI, I see DateTime. I see the same even if I use [GraphQLType(typeof(DateTimeOffset))] or [GraphQLType(typeof(DateTimeOffset?))].

How to fix this?

Code:

[GraphQLType(typeof(DateTimeOffset))]
public DateTimeOffset? EarliestPaymentDate { get; set; }

Schema:

enter image description here

GThree
  • 2,708
  • 7
  • 34
  • 67

1 Answers1

0

GraphQL has no official scalar types for DateTime. Hot chocolate convert DateTime and DateTimeOffset to a custom scalar type

ESG
  • 8,988
  • 3
  • 35
  • 52
  • Does this mean even if graphQl shows this as DateTime in schema, and if my BE has DateTimeOffSet, it will only accept that, not DateTime? – GThree Apr 14 '23 at 18:51
  • Updated my answer as I was wrong. Basically, I suspect that HotChocolate will accept `DateTime` while assuming they are UTC, or `DateTimeOffset` by using the specified offset. – ESG Apr 14 '23 at 18:58