reactive_graph_client/schema_graphql/scalar/
json.rs

1use serde_json::Value;
2use std::fmt::Display;
3use std::fmt::Formatter;
4
5#[derive(cynic::Scalar, Debug, Clone)]
6#[cynic(schema_module = "crate::schema_graphql::schema", graphql_type = "JSON")]
7pub struct Json(pub Value);
8
9impl From<Value> for Json {
10    fn from(value: Value) -> Self {
11        Json(value)
12    }
13}
14
15impl From<Json> for Value {
16    fn from(value: Json) -> Self {
17        value.0
18    }
19}
20
21impl Display for Json {
22    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
23        write!(f, "{}", self.0)
24    }
25}