reactive_graph_client/client/runtime/command/mutations/
execute_command.rs1#[cynic::schema_for_derives(file = r#"../../schema/graphql/reactive-graph-runtime-schema.graphql"#, module = "crate::schema_runtime::schema")]
2pub mod mutations {
3 use serde_json::Value;
4
5 use crate::schema_runtime::property_instance::CommandResult;
7 use crate::schema_runtime::scalar::Json;
8
9 #[derive(cynic::QueryVariables, Debug)]
10 pub struct ExecuteCommandVariables {
11 pub name: String,
12 pub args: Option<Json>,
13 }
14
15 #[derive(cynic::QueryFragment, Debug)]
16 #[cynic(graphql_type = "Mutation", variables = "ExecuteCommandVariables")]
17 pub struct ExecuteCommand {
18 pub commands: MutationCommands,
19 }
20
21 #[derive(cynic::QueryFragment, Debug)]
22 #[cynic(variables = "ExecuteCommandVariables")]
23 pub struct MutationCommands {
24 #[arguments(name: $name, args: $args)]
25 pub execute: Option<CommandResult>,
26 }
27
28 pub fn execute_command(name: String, args: Option<Value>) -> cynic::Operation<ExecuteCommand, ExecuteCommandVariables> {
29 use cynic::MutationBuilder;
30 let vars = ExecuteCommandVariables {
31 name,
32 args: args.map(|value| value.into()),
33 };
34 ExecuteCommand::build(vars)
35 }
36}