reactive_graph_client/client/instances/relations/variables/
id.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::id::UUID;
4    use cynic::QueryVariables;
5    use reactive_graph_graph::NamespacedTypeGetter;
6    use reactive_graph_graph::RelationInstanceId;
7
8    #[derive(QueryVariables, Debug)]
9    pub struct RelationInstanceIdVariables {
10        /// The id of the outbound entity instance.
11        pub outbound_id: UUID,
12        /// The fully qualified namespace of the relation type.
13        #[cynic(rename = "type")]
14        pub _type: String,
15        /// The relation type id type name.
16        pub instance_id: String,
17        /// The id of the inbound entity instance.
18        pub inbound_id: UUID,
19    }
20
21    impl From<&RelationInstanceId> for RelationInstanceIdVariables {
22        fn from(id: &RelationInstanceId) -> Self {
23            let ty = id.ty.relation_type_id();
24            Self {
25                outbound_id: id.outbound_id.into(),
26                _type: ty.namespace().to_string(),
27                instance_id: id.ty.instance_id().to_string(),
28                inbound_id: id.inbound_id.into(),
29            }
30        }
31    }
32}