reactive_graph_dynamic_graph_impl/object/entity/mutation/
mod.rs1use crate::object::entity::mutation::delete::entity_delete_field;
2use crate::object::entity::mutation::export::entity_export_field;
3use crate::object::entity::mutation::trigger::entity_trigger_field;
4use crate::object::entity::mutation::update::entity_update_field;
5use crate::object::types::DynamicGraphTypeDefinition;
6use async_graphql::dynamic::Object;
7use async_graphql::dynamic::SchemaBuilder;
8use reactive_graph_dynamic_graph_api::SchemaBuilderContext;
9use reactive_graph_graph::EntityType;
10
11pub mod delete;
12pub mod export;
13pub mod trigger;
14pub mod update;
15
16pub fn register_entity_type_mutation_objects(mut schema: SchemaBuilder, context: &SchemaBuilderContext) -> SchemaBuilder {
17 for (_, entity_type) in context.entity_type_manager.get_all() {
18 schema = schema.register(create_entity_mutation_object(&entity_type));
19 }
20 schema
21}
22
23pub fn create_entity_mutation_object(entity_type: &EntityType) -> Object {
24 let dy_ty = DynamicGraphTypeDefinition::from(&entity_type.ty);
25 let mut object = Object::new(dy_ty.mutation_type_name());
26 if let Some(update_field) = entity_update_field(entity_type) {
27 object = object.field(update_field);
28 }
29 if let Some(trigger_field) = entity_trigger_field(entity_type) {
30 object = object.field(trigger_field);
31 }
32 object = object.field(entity_export_field());
33 object = object.field(entity_delete_field());
34 object
35}