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 opportunity to represent chrono::NaiveDateTime in milliseconds. #670

Closed
olvyko opened this issue May 26, 2020 · 2 comments
Closed

Add opportunity to represent chrono::NaiveDateTime in milliseconds. #670

olvyko opened this issue May 26, 2020 · 2 comments
Assignees
Labels
Milestone

Comments

@olvyko
Copy link

olvyko commented May 26, 2020

Juniper gives you the opportunity to use chrono::NaiveDateTime but I didn't find a way to represent timestamp in milliseconds.

https://docs.rs/chrono/0.4.11/chrono/naive/serde/index.html
https://docs.rs/chrono/0.4.11/chrono/serde/index.html

At the moment, using serde, I can do this:

use serde::Serialize;
use chrono::naive::serde::ts_milliseconds;

#[derive(Serialize)]
pub struct Example {
    #[serde(with = "ts_milliseconds")]
    pub timestamp: NaiveDateTime,
}
@olvyko olvyko added the enhancement Improvement of existing features or bugfix label May 26, 2020
@tyranron
Copy link
Member

@olvyko you shoud use newtype and implement GraphQLScalar for this purpose.

@olvyko
Copy link
Author

olvyko commented May 26, 2020

@tyranron yeah, I will do that

@tyranron tyranron added support and removed enhancement Improvement of existing features or bugfix labels Jun 1, 2022
@tyranron tyranron self-assigned this Jun 1, 2022
@tyranron tyranron added this to the 0.16.0 milestone Jun 1, 2022
@tyranron tyranron closed this as completed Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants