reactive_graph_client/client/instances/relations/variables/
remove_property.rs1#[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::NamespacedTypeGetter;
6 use reactive_graph_graph::PropertyType;
7 use reactive_graph_graph::PropertyTypes;
8 use reactive_graph_graph::RelationInstanceId;
9
10 #[derive(QueryVariables, Debug)]
11 pub struct RemovePropertiesVariables {
12 pub outbound_id: UUID,
14 #[cynic(rename = "type")]
16 pub _type: String,
17 pub instance_id: String,
19 pub inbound_id: UUID,
21 pub properties: Option<Vec<String>>,
23 }
24
25 impl RemovePropertiesVariables {
26 pub fn new(id: &RelationInstanceId, property_names: Vec<String>) -> Self {
27 let ty = id.ty.relation_type_id();
28 Self {
29 outbound_id: id.outbound_id.into(),
30 _type: ty.namespace().to_string(),
31 instance_id: id.ty.instance_id().to_string(),
32 inbound_id: id.inbound_id.into(),
33 properties: Some(property_names),
34 }
35 }
36
37 pub fn new_from_property_name(id: &RelationInstanceId, property_name: String) -> Self {
38 Self::new(id, vec![property_name])
39 }
40
41 pub fn new_from_property_types<P: Into<PropertyTypes>>(id: &RelationInstanceId, property_types: P) -> Self {
42 let property_types = property_types.into();
43 Self::new(id, property_types.names())
44 }
45 pub fn new_from_property_type<P: Into<PropertyType>>(id: &RelationInstanceId, property_type: P) -> Self {
46 let property_type = property_type.into();
47 Self::new(id, vec![property_type.name.clone()])
48 }
49 }
50}