Merge pull request #604 from Miaxos/fix-serializer-issue
FIX: Serializing issue
This commit is contained in:
commit
dc8a1df659
42
tests/serializer_uuid.rs
Normal file
42
tests/serializer_uuid.rs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
use async_graphql::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[repr(transparent)]
|
||||||
|
#[serde(transparent)]
|
||||||
|
struct AssetId(pub uuid::Uuid);
|
||||||
|
|
||||||
|
async_graphql::scalar!(AssetId);
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
/// Test case for
|
||||||
|
/// https://github.com/async-graphql/async-graphql/issues/603
|
||||||
|
pub async fn test_serialize_uuid() {
|
||||||
|
let generated_uuid = uuid::Uuid::new_v4();
|
||||||
|
|
||||||
|
struct Query {
|
||||||
|
data: AssetId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Object]
|
||||||
|
impl Query {
|
||||||
|
async fn data(&self) -> &AssetId {
|
||||||
|
&self.data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let schema = Schema::new(
|
||||||
|
Query {
|
||||||
|
data: AssetId(generated_uuid),
|
||||||
|
},
|
||||||
|
EmptyMutation,
|
||||||
|
EmptySubscription,
|
||||||
|
);
|
||||||
|
let query = r#"{ data }"#;
|
||||||
|
assert_eq!(
|
||||||
|
schema.execute(query).await.data,
|
||||||
|
value!({
|
||||||
|
"data": generated_uuid.to_string(),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
@ -249,7 +249,7 @@ impl ser::Serializer for Serializer {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_human_readable(&self) -> bool {
|
fn is_human_readable(&self) -> bool {
|
||||||
false
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user