reactive_graph_client/client/instances/entities/variables/
add_property.rs

1#[cynic::schema_for_derives(file = r#"../../schema/graphql/reactive-graph-schema.graphql"#, module = "crate::schema_graphql::schema")]
2pub mod variables {
3    use crate::PropertyTypeDefinition;
4    use crate::PropertyTypeDefinitions;
5    use crate::schema_graphql::scalar::UUID;
6    use cynic::QueryVariables;
7    use reactive_graph_graph::PropertyType;
8    use reactive_graph_graph::PropertyTypes;
9    use uuid::Uuid;
10
11    #[derive(QueryVariables, Debug)]
12    pub struct AddPropertiesVariables {
13        pub id: UUID,
14        pub properties: Option<Vec<PropertyTypeDefinition>>,
15    }
16
17    impl AddPropertiesVariables {
18        pub fn new_property(id: Uuid, property: PropertyType) -> Self {
19            Self {
20                id: id.into(),
21                properties: Some(vec![property.into()]),
22            }
23        }
24
25        pub fn new_properties(id: Uuid, properties: PropertyTypes) -> Self {
26            Self {
27                id: id.into(),
28                properties: Some(PropertyTypeDefinitions::from(properties).0),
29            }
30        }
31    }
32}