From 3456786463e6e24adaa601aa0dcf73e47dc09fcd Mon Sep 17 00:00:00 2001 From: Jean Mertz Date: Thu, 23 May 2019 08:33:01 +0200 Subject: [PATCH] Implement Serialize/Deserialize for ID scalar As per the unofficial Rust API guidelines: https://rust-lang-nursery.github.io/api-guidelines/interoperability.html#data-structures-implement-serdes-serialize-deserialize-c-serde --- juniper/CHANGELOG.md | 2 +- juniper/src/types/scalars.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/juniper/CHANGELOG.md b/juniper/CHANGELOG.md index f1d4c3c3..0b245d26 100644 --- a/juniper/CHANGELOG.md +++ b/juniper/CHANGELOG.md @@ -1,6 +1,6 @@ # master -- No changes yet +- The `ID` scalar now implements Serde's `Serialize` and `Deserialize` # [[0.12.0] 2019-05-16](https://github.com/graphql-rust/juniper/releases/tag/juniper-0.12.0) diff --git a/juniper/src/types/scalars.rs b/juniper/src/types/scalars.rs index 6b969ce5..f0b8f2e0 100644 --- a/juniper/src/types/scalars.rs +++ b/juniper/src/types/scalars.rs @@ -1,3 +1,4 @@ +use serde_derive::{Deserialize, Serialize}; use std::convert::From; use std::marker::PhantomData; use std::ops::Deref; @@ -13,7 +14,7 @@ use crate::value::{ParseScalarResult, ScalarRefValue, ScalarValue, Value}; /// An ID as defined by the GraphQL specification /// /// Represented as a string, but can be converted _to_ from an integer as well. -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] pub struct ID(String); impl From for ID {