reactive_graph_dynamic_graph_impl/field/
json.rs

1use async_graphql::ID;
2use async_graphql::dynamic::FieldValue;
3use serde_json::Value;
4use uuid::Uuid;
5
6pub fn to_field_value<'a>(v: Value) -> Option<FieldValue<'a>> {
7    async_graphql::to_value(v).map(FieldValue::value).ok()
8}
9
10pub fn id_to_field_value<'a, ID: Into<Uuid>>(id: ID) -> FieldValue<'a> {
11    FieldValue::value(ID(id.into().to_string()))
12}
13
14pub fn ids_to_field_value<'a>(ids: Vec<Uuid>) -> FieldValue<'a> {
15    FieldValue::list(ids.iter().cloned().map(id_to_field_value))
16}