reactive_graph_dynamic_graph_impl/field/entity/
id.rs1use crate::interface::entity::INTERFACE_ENTITY_FIELD_ID;
2use async_graphql::ID;
3use async_graphql::dynamic::Field;
4use async_graphql::dynamic::FieldFuture;
5use async_graphql::dynamic::FieldValue;
6use async_graphql::dynamic::TypeRef;
7use reactive_graph_reactive_model_impl::ReactiveEntity;
8
9pub fn entity_id_field() -> Field {
10 Field::new(INTERFACE_ENTITY_FIELD_ID, TypeRef::named_nn(TypeRef::ID), |ctx| {
11 FieldFuture::new(async move {
12 let entity_instance = ctx.parent_value.try_downcast_ref::<ReactiveEntity>()?;
13 Ok(Some(FieldValue::value(ID(entity_instance.id.to_string()))))
14 })
15 })
16}