data-api-builder icon indicating copy to clipboard operation
data-api-builder copied to clipboard

Add Support for DateOnly type

Open abhishekkumams opened this issue 1 year ago • 7 comments

Currently, GraphQL response is showing DateTimeFormat for date type columns.

If the value stored in the DB is 11-03-2017, graphql will show 11-03-2017T00:00:00Z.

image image

abhishekkumams avatar Jul 27 '23 06:07 abhishekkumams

@Aniruddh25, should we do this as well (Now, that we know how to do it and it will be easier to consume). Maybe we can take this up in a future milestone?

abhishekkumams avatar Jul 27 '23 06:07 abhishekkumams

@abhishekkumams, makes sense - I wonder why is that the case isn't Date type mapped to HotChocolate Date? https://chillicream.com/docs/hotchocolate/v13/defining-a-schema/scalars#net-scalars

Aniruddh25 avatar Jul 29 '23 23:07 Aniruddh25

@abhishekkumams, makes sense - I wonder why is that the case isn't Date type mapped to HotChocolate Date? https://chillicream.com/docs/hotchocolate/v13/defining-a-schema/scalars#net-scalars

Nope, It's mapped to DateTime

abhishekkumams avatar Aug 01 '23 09:08 abhishekkumams

@abhishekkumams,

I went back into the previous changes and found this reasoning in the commit: https://github.com/Azure/data-api-builder/commit/63d5ef24e3bb90057fed015caa1d81f222de232a:

  • DateTime This is a bit of a tricky one. DateTime type is handled by HotChocolate as DateTimeOffset. Also, our db column type detection method gives DateTime for all Date, DateTime, and DateTimeOffset. Meaning that while the user can define non DateTimeOffset columns, they will be interpreted as DateTimeOffset and the gaps will be filled with 00:00:00 time and local offset. HotChocolate also provides us with Date type. However, because all db column types Date, DateTime, and DateTimeOffset are detected as DateTime system types, we cannot make use of the HotChocolate Date type as of now.

So, to solve this, we would need to look for alternative ways for db column type to system type detection method other than ADO.NET Db Data provider.

Aniruddh25 avatar Aug 02 '23 18:08 Aniruddh25

@ayush3797 is this duplicate or secondary to your date work?

seantleonard avatar Nov 16 '23 16:11 seantleonard

@ayush3797 is this duplicate or secondary to your date work?

Its not.

ayush3797 avatar Jan 03 '24 06:01 ayush3797

@abhishekkumams i wonder if your work enabling SqlDbType SqlParameter work would help here. When reading the db schema from MsSql, are we able to parse out a specific SqlDbType? or are we still restricted to the limitations of DbType values as explained in Ani's quote

DateTime https://github.com/Azure/data-api-builder/commit/63d5ef24e3bb90057fed015caa1d81f222de232a This is a bit of a tricky one. DateTime type is handled by HotChocolate as DateTimeOffset. Also, our db column type detection method gives DateTime for all Date, DateTime, and DateTimeOffset. Meaning that while the user can define non DateTimeOffset columns, they will be interpreted as DateTimeOffset and the gaps will be filled with 00:00:00 time and local offset. HotChocolate also provides us with Date type. However, because all db column types Date, DateTime, and DateTimeOffset are detected as DateTime system types, we cannot make use of the HotChocolate Date type as of now.

seantleonard avatar Apr 19 '24 17:04 seantleonard