Skip to content

Commit

Permalink
fix: specifically use serde::Serialize in Scalar derive (#909)
Browse files Browse the repository at this point in the history
#### Why are we making this change?

It was reported [here](#908)
that `rust_decimal::Decimal` errored out when `derive(cynic::Scalar)`
was used on it. This turned out to be because that `Decimal` type
defines its own `serialize` function in addition to implementing
`Serialize` and the `Scalar` derive was accidentally using that.

#### What effects does this change have?

Updaates the `Scalar` derive to specifically use
`serde::Serialize::serialize`
  • Loading branch information
obmarg authored Apr 10, 2024
1 parent 1f3fd8e commit b72ce05
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cynic-codegen/src/scalar_derive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn scalar_derive_impl(input: ScalarDeriveInput) -> Result<TokenStream, syn::
where
__S: cynic::serde::Serializer,
{
self.0.serialize(serializer)
<#inner_type as cynic::serde::Serialize>::serialize(&self.0, serializer)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ impl cynic::serde::Serialize for DateTime {
where
__S: cynic::serde::Serializer,
{
self.0.serialize(serializer)
<String as cynic::serde::Serialize>::serialize(&self.0, serializer)
}
}
#[automatically_derived]
Expand Down

0 comments on commit b72ce05

Please sign in to comment.