From 68210f54caa22fca46d37b9ab6829220aebcc4bb Mon Sep 17 00:00:00 2001
From: Stijn Frishert <stijnfrishert@gmail.com>
Date: Sat, 10 Oct 2020 16:17:33 +0200
Subject: [PATCH] impl Display for ID (#783)

---
 juniper/src/types/scalars.rs | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/juniper/src/types/scalars.rs b/juniper/src/types/scalars.rs
index 830847e4..3ebac39c 100644
--- a/juniper/src/types/scalars.rs
+++ b/juniper/src/types/scalars.rs
@@ -1,4 +1,6 @@
-use std::{char, convert::From, marker::PhantomData, ops::Deref, rc::Rc, thread::JoinHandle, u32};
+use std::{
+    char, convert::From, fmt, marker::PhantomData, ops::Deref, rc::Rc, thread::JoinHandle, u32,
+};
 
 use serde::{Deserialize, Serialize};
 
@@ -42,6 +44,12 @@ impl Deref for ID {
     }
 }
 
+impl fmt::Display for ID {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        self.0.fmt(f)
+    }
+}
+
 #[crate::graphql_scalar(name = "ID")]
 impl<S> GraphQLScalar for ID
 where
@@ -488,6 +496,12 @@ mod tests {
         assert_eq!(id.len(), 3);
     }
 
+    #[test]
+    fn test_id_display() {
+        let id = ID(String::from("foo"));
+        assert_eq!(format!("{}", id), "foo");
+    }
+
     #[test]
     fn parse_strings() {
         fn parse_string(s: &str, expected: &str) {