reactive_graph_graphql_impl/
graphql_schema_manager_impl.rs

1use std::sync::Arc;
2
3use async_graphql::Schema;
4use async_trait::async_trait;
5use springtime_di::Component;
6use springtime_di::component_alias;
7
8use reactive_graph_behaviour_service_api::EntityBehaviourManager;
9use reactive_graph_behaviour_service_api::EntityBehaviourRegistry;
10use reactive_graph_behaviour_service_api::EntityComponentBehaviourManager;
11use reactive_graph_behaviour_service_api::EntityComponentBehaviourRegistry;
12use reactive_graph_behaviour_service_api::RelationBehaviourManager;
13use reactive_graph_behaviour_service_api::RelationBehaviourRegistry;
14use reactive_graph_behaviour_service_api::RelationComponentBehaviourManager;
15use reactive_graph_behaviour_service_api::RelationComponentBehaviourRegistry;
16use reactive_graph_graphql_api::GraphQLSchemaManager;
17use reactive_graph_graphql_schema::ReactiveGraphMutation;
18use reactive_graph_graphql_schema::ReactiveGraphQuery;
19use reactive_graph_graphql_schema::ReactiveGraphSchema;
20use reactive_graph_graphql_schema::ReactiveGraphSubscription;
21use reactive_graph_graphql_schema::directives;
22use reactive_graph_lifecycle::Lifecycle;
23use reactive_graph_reactive_service_api::ReactiveEntityManager;
24use reactive_graph_reactive_service_api::ReactiveFlowManager;
25use reactive_graph_reactive_service_api::ReactiveRelationManager;
26use reactive_graph_type_system_api::ComponentManager;
27use reactive_graph_type_system_api::EntityTypeManager;
28use reactive_graph_type_system_api::FlowTypeManager;
29use reactive_graph_type_system_api::NamespaceManager;
30use reactive_graph_type_system_api::RelationTypeManager;
31
32#[derive(Component)]
33pub struct GraphQLSchemaManagerImpl {
34    component_manager: Arc<dyn ComponentManager + Send + Sync>,
35
36    entity_type_manager: Arc<dyn EntityTypeManager + Send + Sync>,
37
38    relation_type_manager: Arc<dyn RelationTypeManager + Send + Sync>,
39
40    flow_type_manager: Arc<dyn FlowTypeManager + Send + Sync>,
41
42    namespace_manager: Arc<dyn NamespaceManager + Send + Sync>,
43
44    entity_instance_manager: Arc<dyn ReactiveEntityManager + Send + Sync>,
45
46    relation_instance_manager: Arc<dyn ReactiveRelationManager + Send + Sync>,
47
48    flow_instance_manager: Arc<dyn ReactiveFlowManager + Send + Sync>,
49
50    entity_behaviour_registry: Arc<dyn EntityBehaviourRegistry + Send + Sync>,
51
52    entity_component_behaviour_registry: Arc<dyn EntityComponentBehaviourRegistry + Send + Sync>,
53
54    relation_behaviour_registry: Arc<dyn RelationBehaviourRegistry + Send + Sync>,
55
56    relation_component_behaviour_registry: Arc<dyn RelationComponentBehaviourRegistry + Send + Sync>,
57
58    entity_behaviour_manager: Arc<dyn EntityBehaviourManager + Send + Sync>,
59
60    entity_component_behaviour_manager: Arc<dyn EntityComponentBehaviourManager + Send + Sync>,
61
62    relation_behaviour_manager: Arc<dyn RelationBehaviourManager + Send + Sync>,
63
64    relation_component_behaviour_manager: Arc<dyn RelationComponentBehaviourManager + Send + Sync>,
65}
66
67impl GraphQLSchemaManagerImpl {}
68
69#[async_trait]
70#[component_alias]
71impl GraphQLSchemaManager for GraphQLSchemaManagerImpl {
72    fn get_schema(&self) -> ReactiveGraphSchema {
73        Schema::build(ReactiveGraphQuery, ReactiveGraphMutation, ReactiveGraphSubscription)
74            .with_sorted_fields()
75            .with_sorted_enums()
76            .data(self.component_manager.clone())
77            .data(self.entity_type_manager.clone())
78            .data(self.relation_type_manager.clone())
79            .data(self.flow_type_manager.clone())
80            .data(self.namespace_manager.clone())
81            .data(self.entity_instance_manager.clone())
82            .data(self.relation_instance_manager.clone())
83            .data(self.flow_instance_manager.clone())
84            .data(self.entity_behaviour_registry.clone())
85            .data(self.entity_component_behaviour_registry.clone())
86            .data(self.relation_behaviour_registry.clone())
87            .data(self.relation_component_behaviour_registry.clone())
88            .data(self.entity_behaviour_manager.clone())
89            .data(self.entity_component_behaviour_manager.clone())
90            .data(self.relation_behaviour_manager.clone())
91            .data(self.relation_component_behaviour_manager.clone())
92            .directive(directives::concat)
93            .directive(directives::random_uuid)
94            .finish()
95    }
96}
97
98#[async_trait]
99impl Lifecycle for GraphQLSchemaManagerImpl {
100    async fn init(&self) {}
101
102    async fn post_init(&self) {}
103
104    async fn pre_shutdown(&self) {}
105
106    async fn shutdown(&self) {}
107}