Skip to content

Conversation

@davidbarsky
Copy link

Bit of a draft, but adding jiff for the same reasons as outlined in jj-vcs/jj#8038.

@davidbarsky davidbarsky changed the title chore: add jiff-0_2 chore: add jiff behind a feature flag Nov 17, 2025
Copy link
Collaborator

@ipetkov ipetkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, thanks for working on this!

Mostly have some questions around scalar names (and whether we can make the actual Rust time backend opaque to the schema consumers)

Feel free to flip this out of draft and get the CI to run whenever you're ready

Comment on lines +7 to +10
#[cfg(all(feature = "jiff-0_2", not(feature = "chrono")))]
use jiff::Timestamp;
#[cfg(feature = "chrono")]
use chrono::{DateTime, Utc};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with the apollo tracing extension requiring jiff and not supporting chrono here (should be easier without having to deal with the cfg soup)

[features]
apollo_persisted_queries = ["lru", "sha2"]
apollo_tracing = ["chrono"]
apollo_tracing = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comment, I'm fine with this requiring dep:jiff

#[Scalar(
internal,
name = "Duration",
name = "ChronoDuration",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep this scalar name as Duration or will it collide with jiff's version?

The reason I ask is because if these are meant to be ISO 8601 durations, then the backing implementation (whether chrono or jiff) shouldn't actually matter to a GraphQL consumer. Also swapping one backend for another shouldn't require churning the schemas (assuming they are being either committed somewhere or the consumers are using something like Apollo Client for code generation)

Comment on lines 10 to 52
name = "ChronoDateTimeFixedOffset",
specified_by_url = "https://datatracker.ietf.org/doc/html/rfc3339"
)]
impl ScalarType for DateTime<FixedOffset> {
fn parse(value: Value) -> InputValueResult<Self> {
match &value {
Value::String(s) => Ok(s.parse::<DateTime<FixedOffset>>()?),
_ => Err(InputValueError::expected_type(value)),
}
}

fn to_value(&self) -> Value {
Value::String(self.to_rfc3339())
}
}

/// Implement the DateTime<Local> scalar
///
/// The input/output is a string in RFC3339 format.
#[Scalar(
internal,
name = "DateTime",
name = "ChronoDateTimeLocal",
specified_by_url = "https://datatracker.ietf.org/doc/html/rfc3339"
)]
impl ScalarType for DateTime<Local> {
fn parse(value: Value) -> InputValueResult<Self> {
match &value {
Value::String(s) => Ok(s.parse::<DateTime<Local>>()?),
_ => Err(InputValueError::expected_type(value)),
}
}

fn to_value(&self) -> Value {
Value::String(self.to_rfc3339())
}
}

/// Implement the DateTime<Utc> scalar
///
/// The input/output is a string in RFC3339 format.
#[Scalar(
internal,
name = "DateTime",
name = "ChronoDateTime",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment on keeping the names the same as before

#[Scalar(
internal,
name = "TimeZone",
name = "ChronoTz",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment


use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};

#[Scalar(internal, name = "JiffDate")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment on these scalar names, is it possible to use the same scalar name as chrono uses to avoid churning the actual schema?

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.

2 participants