1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
use async_graphql::{Enum, Object};
use derive_more::{From, Into};
use entity::{Edge, EdgeDeletionPolicy, EdgeValue, EdgeValueType, Id};
#[derive(From, Into)]
pub struct GqlEdge(Edge);
#[Object]
impl GqlEdge {
#[graphql(name = "name")]
async fn gql_name(&self) -> &str {
self.0.name()
}
#[graphql(name = "type")]
async fn gql_type(&self) -> GqlEdgeValueType {
GqlEdgeValueType::from(self.0.to_type())
}
#[graphql(name = "value")]
async fn gql_value(&self) -> GqlEdgeValue {
GqlEdgeValue::from(self.0.value().clone())
}
#[graphql(name = "ids")]
async fn gql_ids(&self) -> Vec<Id> {
self.0.to_ids()
}
#[graphql(name = "deletion_policy")]
async fn gql_deletion_policy(&self) -> GqlEdgeDeletionPolicy {
GqlEdgeDeletionPolicy::from(self.0.deletion_policy())
}
}
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, Enum)]
#[graphql(remote = "EdgeDeletionPolicy")]
pub enum GqlEdgeDeletionPolicy {
Nothing,
ShallowDelete,
DeepDelete,
}
#[derive(From, Into)]
pub struct GqlEdgeValue(EdgeValue);
#[Object]
impl GqlEdgeValue {
#[graphql(name = "ids")]
async fn gql_ids(&self) -> Vec<Id> {
self.0.to_ids()
}
#[graphql(name = "type")]
async fn gql_type(&self) -> GqlEdgeValueType {
GqlEdgeValueType::from(self.0.to_type())
}
}
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, Enum)]
#[graphql(remote = "EdgeValueType")]
pub enum GqlEdgeValueType {
MaybeOne,
One,
Many,
}