ChilliCream / ChilliCream/graphql-platform

Wanted: More control over how dates are serialized and what date types are used

Open
#6,905 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🌶️ strawberry shake Area: Scalars
Dominant language
C#
Stars
5.8k
Forks
810
Avg merge
15h 39m
Merged PRs (30d)
98

Description

Product

Strawberry Shake

Is your feature request related to a problem?

I'm a big fan of Strawberry Shake, but I've run into an issue with a GQL API we're using. This API relies on UTC for all datetimes internally. However, when we parse these dates into DateTimeOffset, they end up with the local offset because the GQL API doesn't include an offset in its dates (for example, 2024-05-31T12:00:01). This causes confusion when we round trip the dates, as the GQL API correctly parses the offset on our dates.

To work around this, we're currently adding custom code for each DateTimeOffset field to discard the offset, which is a bit of a hassle.

The solution you'd like

After checking the source code, specifically DateTimeSerializer.cs, I think it would be helpful to have an extension that lets us have more control over how the parsing works. It would be great if we could specify things like DateTimeStyles and CultureInfo for more flexibility and compatibility.

Additionally, there might be cases where creating our own datetime types could help us deal with issues caused by troublesome APIs.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Strawberry Shake's DateTimeSerializer.cs and trace how API dates are parsed into DateTimeOffset values. Determine the supported scope for configurable DateTimeStyles, CultureInfo, and custom datetime types; the work is done when the requested serialization controls and their behavior are clearly defined and covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.