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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
use position::Pos;
pub use common::{Directive, Number, Value, Name, Type};
#[derive(Debug, Clone, PartialEq)]
pub struct Document {
pub definitions: Vec<Definition>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum Definition {
Operation(OperationDefinition),
Fragment(FragmentDefinition),
}
#[derive(Debug, Clone, PartialEq)]
pub struct FragmentDefinition {
pub position: Pos,
pub name: Name,
pub type_condition: TypeCondition,
pub directives: Vec<Directive>,
pub selection_set: SelectionSet,
}
#[derive(Debug, Clone, PartialEq)]
pub enum OperationDefinition {
SelectionSet(SelectionSet),
Query(Query),
Mutation(Mutation),
Subscription(Subscription),
}
#[derive(Debug, Clone, PartialEq)]
pub struct Query {
pub position: Pos,
pub name: Option<Name>,
pub variable_definitions: Vec<VariableDefinition>,
pub directives: Vec<Directive>,
pub selection_set: SelectionSet,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Mutation {
pub position: Pos,
pub name: Option<Name>,
pub variable_definitions: Vec<VariableDefinition>,
pub directives: Vec<Directive>,
pub selection_set: SelectionSet,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Subscription {
pub position: Pos,
pub name: Option<Name>,
pub variable_definitions: Vec<VariableDefinition>,
pub directives: Vec<Directive>,
pub selection_set: SelectionSet,
}
#[derive(Debug, Clone, PartialEq)]
pub struct SelectionSet {
pub span: (Pos, Pos),
pub items: Vec<Selection>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct VariableDefinition {
pub position: Pos,
pub name: Name,
pub var_type: Type,
pub default_value: Option<Value>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum Selection {
Field(Field),
FragmentSpread(FragmentSpread),
InlineFragment(InlineFragment),
}
#[derive(Debug, Clone, PartialEq)]
pub struct Field {
pub position: Pos,
pub alias: Option<Name>,
pub name: Name,
pub arguments: Vec<(Name, Value)>,
pub directives: Vec<Directive>,
pub selection_set: SelectionSet,
}
#[derive(Debug, Clone, PartialEq)]
pub struct FragmentSpread {
pub position: Pos,
pub fragment_name: Name,
pub directives: Vec<Directive>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum TypeCondition {
On(Name),
}
#[derive(Debug, Clone, PartialEq)]
pub struct InlineFragment {
pub position: Pos,
pub type_condition: Option<TypeCondition>,
pub directives: Vec<Directive>,
pub selection_set: SelectionSet,
}