Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add GraphQL::Types::ISO8601DateTime.time_precision to customize time pricisions #1845

Merged
merged 1 commit into from
Sep 10, 2018

Conversation

gfx
Copy link
Contributor

@gfx gfx commented Sep 10, 2018

The result of Time.zone.now.to_json (Rails' datetime format) differs from GraphQL::Types::ISO8601's serialized one:

  • Rails': "2010-02-02T22:30:30.124-06:00" (ISO8601 with miliseconds)
  • GraphQL-Ruby's: "2010-02-02T22:30:30-06:00" (ISO8601 without milliseconds)

This incompatibility causes problems in my project 😭, so I have monkey-patched to GraphQL::Types::ISO8601 for now.

This PR provides a way to customize the precision of the serialized format just like ActiveSupport::JSON::Encoding.time_precision.

Usage:

# in a file, e.g. my_schema.rb
GraphQL::Types::ISO8601.time_precision = ActiveSupport::JSON::Encoding.time_precision

No breaking change is introduced by the PR.

@rmosolgo rmosolgo added this to the 1.8.9 milestone Sep 10, 2018
@rmosolgo
Copy link
Owner

Awesome, thanks for adding this improvement!

@rmosolgo rmosolgo merged commit c4c224f into rmosolgo:master Sep 10, 2018
@gfx gfx deleted the add_time_precision branch September 11, 2018 01:03
@gfx
Copy link
Contributor Author

gfx commented Sep 11, 2018

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants