Azure / data-api-builder

Data API builder provides modern REST and GraphQL endpoints to your Azure Databases and on-prem stores.
https://aka.ms/dab/docs
MIT License
919 stars 189 forks source link

Add Support for DateOnly type #1610

Open abhishekkumams opened 1 year ago

abhishekkumams commented 1 year ago

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 commented 1 year ago

@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?

Aniruddh25 commented 1 year ago

@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

abhishekkumams commented 1 year ago

@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

Aniruddh25 commented 1 year ago

@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.

seantleonard commented 11 months ago

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

ayush3797 commented 10 months ago

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

Its not.

seantleonard commented 6 months ago

@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.