reactive_graph_client/schema_runtime/
scalar.rs

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