reactive_graph_client/client/instances/entities/variables/
remove_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::schema_graphql::scalar::UUID;
4    use cynic::QueryVariables;
5    use reactive_graph_graph::PropertyType;
6    use reactive_graph_graph::PropertyTypes;
7    use uuid::Uuid;
8
9    #[derive(QueryVariables, Debug)]
10    pub struct RemovePropertiesVariables {
11        pub id: UUID,
12        pub properties: Option<Vec<String>>,
13    }
14
15    impl RemovePropertiesVariables {
16        pub fn new_by_name<S: Into<String>>(id: Uuid, property_name: S) -> Self {
17            Self {
18                id: id.into(),
19                properties: Some(vec![property_name.into()]),
20            }
21        }
22
23        pub fn new_by_type<P: Into<PropertyType>>(id: Uuid, property_type: P) -> Self {
24            Self {
25                id: id.into(),
26                properties: Some(vec![property_type.into().name]),
27            }
28        }
29
30        pub fn new_by_names(id: Uuid, property_names: Vec<String>) -> Self {
31            Self {
32                id: id.into(),
33                properties: Some(property_names),
34            }
35        }
36
37        pub fn new_by_types(id: Uuid, property_types: &PropertyTypes) -> Self {
38            Self {
39                id: id.into(),
40                properties: Some(property_types.iter().map(|property_type| property_type.name.clone()).collect()),
41            }
42        }
43    }
44}