ash-project / ash_graphql

The extension for building GraphQL APIs with Ash
https://hexdocs.pm/ash_graphql
MIT License
73 stars 49 forks source link

UTC timestamps are improperly formatted (bug) #98

Closed smt116 closed 8 months ago

smt116 commented 1 year ago

I have an attribute that is utc_datetime_usec on the resource side. That resource can be accessed by the GraphQL API consumer. It behaves properly in the iex console:

iex([filtered]@localhost)5> [filtered].Broker.get_quote_by_id!("fd941de4-d9f0-4419-8265-1bead97af732", authorize?: false).expires_at
~U[2023-10-30 14:01:10.918342Z]

However, the GraphQL result is missing the UTC suffix:

Zrzut ekranu 2023-10-30 o 15 04 09

which breaks frontend code that tries to parse it into a dayjs object.

zachdaniel commented 8 months ago

Somehow this fell off my radar, sorry. Ultimately datetime formatting is done by absinthe. I think you are using the backwards compatibility option:

config :ash, :utc_datetime_type, :naive_datetime

That should be set to :datetime which will get you a properly formatted datetime.