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
This commit is contained in:
Jean Mertz 2019-05-23 08:33:01 +02:00 committed by theduke
parent 5b9a0bd31b
commit 3456786463
2 changed files with 3 additions and 2 deletions

View file

@ -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)

View file

@ -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<String> for ID {