reactive_graph_dynamic_graph_api/
interface_manager.rs

1use async_graphql::dynamic::Interface;
2use async_trait::async_trait;
3use reactive_graph_graph::Component;
4use reactive_graph_lifecycle::Lifecycle;
5use springtime_di::injectable;
6
7pub const INTERFACE_ENTITY: &str = "Entity";
8pub const INTERFACE_ENTITY_FIELD_ID: &str = "id";
9
10pub const INTERFACE_RELATION: &str = "Relation";
11pub const INTERFACE_RELATION_FIELD_ID: &str = "id";
12pub const INTERFACE_RELATION_FIELD_INSTANCE_ID: &str = "instance_id";
13
14pub const INTERFACE_FLOW: &str = "Flow";
15pub const INTERFACE_FLOW_FIELD_ID: &str = "id";
16
17#[injectable]
18#[async_trait]
19pub trait InterfaceManager: Send + Sync + Lifecycle {
20    /// Returns the interfaces of the dynamic graph.
21    fn get_interfaces(&self) -> Vec<Interface>;
22
23    /// Constructs an interface for the given component.
24    fn get_component_interface(&self, component: Component) -> Interface;
25
26    /// Constructs an interface for entity types. Each entity type has an id field.
27    fn get_entity_interface(&self) -> Interface;
28
29    /// Constructs an interface for relation types. Each relation type has fields for the relation
30    /// type and the relation type instance id.
31    fn get_relation_interface(&self) -> Interface;
32
33    /// Constructs an interface for flow types. Each flow type has an id field which returns the id
34    /// of the wrapper entity instance.
35    fn get_flow_interface(&self) -> Interface;
36}