reactive_graph_dynamic_graph_impl/object/flow/mutation/
mod.rs

1use crate::object::flow::mutation::delete::get_flow_delete_field;
2use crate::object::flow::mutation::trigger::get_flow_type_trigger_field;
3use crate::object::flow::mutation::update::get_flow_update_field;
4use crate::object::types::DynamicGraphTypeDefinition;
5use async_graphql::dynamic::Object;
6use async_graphql::dynamic::SchemaBuilder;
7use reactive_graph_dynamic_graph_api::SchemaBuilderContext;
8use reactive_graph_graph::FlowType;
9use reactive_graph_graph::FlowTypeId;
10
11pub mod delete;
12pub mod export;
13pub mod trigger;
14pub mod update;
15
16pub fn register_flow_type_mutation_objects(mut schema: SchemaBuilder, context: &SchemaBuilderContext) -> SchemaBuilder {
17    for (flow_ty, flow_type) in context.flow_type_manager.get_all() {
18        schema = schema.register(get_flow_mutation_type(&flow_ty, &flow_type, context));
19    }
20    schema
21}
22
23pub fn get_flow_mutation_type(flow_ty: &FlowTypeId, flow_type: &FlowType, context: &SchemaBuilderContext) -> Object {
24    let dy_ty = DynamicGraphTypeDefinition::from(flow_ty);
25    let mut object = Object::new(dy_ty.mutation_type_name());
26    if let Some(update_field) = get_flow_update_field(flow_type, context) {
27        object = object.field(update_field);
28    }
29    if let Some(trigger_field) = get_flow_type_trigger_field(flow_type) {
30        object = object.field(trigger_field);
31    }
32    object = object.field(get_flow_delete_field());
33    object
34}