@@ -48,22 +48,43 @@ pub enum TypeExtension {
48
48
InputObject ( InputObjectTypeExtension ) ,
49
49
}
50
50
51
- #[ derive( Debug , Clone , Default , PartialEq ) ]
51
+ #[ derive( Debug , Clone , PartialEq ) ]
52
52
pub struct ScalarType {
53
53
pub position : Pos ,
54
54
pub description : Option < String > ,
55
55
pub name : Name ,
56
56
pub directives : Vec < Directive > ,
57
57
}
58
58
59
- #[ derive( Debug , Clone , Default , PartialEq ) ]
59
+ impl ScalarType {
60
+ pub fn new ( name : Name ) -> Self {
61
+ Self {
62
+ position : Pos :: default ( ) ,
63
+ description : None ,
64
+ name,
65
+ directives : vec ! [ ] ,
66
+ }
67
+ }
68
+ }
69
+
70
+ #[ derive( Debug , Clone , PartialEq ) ]
60
71
pub struct ScalarTypeExtension {
61
72
pub position : Pos ,
62
73
pub name : Name ,
63
74
pub directives : Vec < Directive > ,
64
75
}
65
76
66
- #[ derive( Debug , Clone , Default , PartialEq ) ]
77
+ impl ScalarTypeExtension {
78
+ pub fn new ( name : Name ) -> Self {
79
+ Self {
80
+ position : Pos :: default ( ) ,
81
+ name,
82
+ directives : vec ! [ ] ,
83
+ }
84
+ }
85
+ }
86
+
87
+ #[ derive( Debug , Clone , PartialEq ) ]
67
88
pub struct ObjectType {
68
89
pub position : Pos ,
69
90
pub description : Option < String > ,
@@ -73,7 +94,20 @@ pub struct ObjectType {
73
94
pub fields : Vec < Field > ,
74
95
}
75
96
76
- #[ derive( Debug , Clone , Default , PartialEq ) ]
97
+ impl ObjectType {
98
+ pub fn new ( name : Name ) -> Self {
99
+ Self {
100
+ position : Pos :: default ( ) ,
101
+ description : None ,
102
+ name,
103
+ implements_interfaces : vec ! [ ] ,
104
+ directives : vec ! [ ] ,
105
+ fields : vec ! [ ] ,
106
+ }
107
+ }
108
+ }
109
+
110
+ #[ derive( Debug , Clone , PartialEq ) ]
77
111
pub struct ObjectTypeExtension {
78
112
pub position : Pos ,
79
113
pub name : Name ,
@@ -82,6 +116,18 @@ pub struct ObjectTypeExtension {
82
116
pub fields : Vec < Field > ,
83
117
}
84
118
119
+ impl ObjectTypeExtension {
120
+ pub fn new ( name : Name ) -> Self {
121
+ Self {
122
+ position : Pos :: default ( ) ,
123
+ name,
124
+ implements_interfaces : vec ! [ ] ,
125
+ directives : vec ! [ ] ,
126
+ fields : vec ! [ ] ,
127
+ }
128
+ }
129
+ }
130
+
85
131
#[ derive( Debug , Clone , PartialEq ) ]
86
132
pub struct Field {
87
133
pub position : Pos ,
@@ -102,7 +148,7 @@ pub struct InputValue {
102
148
pub directives : Vec < Directive > ,
103
149
}
104
150
105
- #[ derive( Debug , Clone , Default , PartialEq ) ]
151
+ #[ derive( Debug , Clone , PartialEq ) ]
106
152
pub struct InterfaceType {
107
153
pub position : Pos ,
108
154
pub description : Option < String > ,
@@ -111,15 +157,38 @@ pub struct InterfaceType {
111
157
pub fields : Vec < Field > ,
112
158
}
113
159
114
- #[ derive( Debug , Clone , Default , PartialEq ) ]
160
+ impl InterfaceType {
161
+ pub fn new ( name : Name ) -> Self {
162
+ Self {
163
+ position : Pos :: default ( ) ,
164
+ description : None ,
165
+ name,
166
+ directives : vec ! [ ] ,
167
+ fields : vec ! [ ] ,
168
+ }
169
+ }
170
+ }
171
+
172
+ #[ derive( Debug , Clone , PartialEq ) ]
115
173
pub struct InterfaceTypeExtension {
116
174
pub position : Pos ,
117
175
pub name : Name ,
118
176
pub directives : Vec < Directive > ,
119
177
pub fields : Vec < Field > ,
120
178
}
121
179
122
- #[ derive( Debug , Clone , Default , PartialEq ) ]
180
+ impl InterfaceTypeExtension {
181
+ pub fn new ( name : Name ) -> Self {
182
+ Self {
183
+ position : Pos :: default ( ) ,
184
+ name,
185
+ directives : vec ! [ ] ,
186
+ fields : vec ! [ ] ,
187
+ }
188
+ }
189
+ }
190
+
191
+ #[ derive( Debug , Clone , PartialEq ) ]
123
192
pub struct UnionType {
124
193
pub position : Pos ,
125
194
pub description : Option < String > ,
@@ -128,15 +197,38 @@ pub struct UnionType {
128
197
pub types : Vec < NamedType > ,
129
198
}
130
199
131
- #[ derive( Debug , Clone , Default , PartialEq ) ]
200
+ impl UnionType {
201
+ pub fn new ( name : Name ) -> Self {
202
+ Self {
203
+ position : Pos :: default ( ) ,
204
+ description : None ,
205
+ name,
206
+ directives : vec ! [ ] ,
207
+ types : vec ! [ ] ,
208
+ }
209
+ }
210
+ }
211
+
212
+ #[ derive( Debug , Clone , PartialEq ) ]
132
213
pub struct UnionTypeExtension {
133
214
pub position : Pos ,
134
215
pub name : Name ,
135
216
pub directives : Vec < Directive > ,
136
217
pub types : Vec < NamedType > ,
137
218
}
138
219
139
- #[ derive( Debug , Clone , Default , PartialEq ) ]
220
+ impl UnionTypeExtension {
221
+ pub fn new ( name : Name ) -> Self {
222
+ Self {
223
+ position : Pos :: default ( ) ,
224
+ name,
225
+ directives : vec ! [ ] ,
226
+ types : vec ! [ ] ,
227
+ }
228
+ }
229
+ }
230
+
231
+ #[ derive( Debug , Clone , PartialEq ) ]
140
232
pub struct EnumType {
141
233
pub position : Pos ,
142
234
pub description : Option < String > ,
@@ -145,23 +237,57 @@ pub struct EnumType {
145
237
pub values : Vec < EnumValue > ,
146
238
}
147
239
148
- #[ derive( Debug , Clone , Default , PartialEq ) ]
240
+ impl EnumType {
241
+ pub fn new ( name : Name ) -> Self {
242
+ Self {
243
+ position : Pos :: default ( ) ,
244
+ description : None ,
245
+ name,
246
+ directives : vec ! [ ] ,
247
+ values : vec ! [ ] ,
248
+ }
249
+ }
250
+ }
251
+
252
+ #[ derive( Debug , Clone , PartialEq ) ]
149
253
pub struct EnumValue {
150
254
pub position : Pos ,
151
255
pub description : Option < String > ,
152
256
pub name : Name ,
153
257
pub directives : Vec < Directive > ,
154
258
}
155
259
156
- #[ derive( Debug , Clone , Default , PartialEq ) ]
260
+ impl EnumValue {
261
+ pub fn new ( name : Name ) -> Self {
262
+ Self {
263
+ position : Pos :: default ( ) ,
264
+ description : None ,
265
+ name,
266
+ directives : vec ! [ ] ,
267
+ }
268
+ }
269
+ }
270
+
271
+ #[ derive( Debug , Clone , PartialEq ) ]
157
272
pub struct EnumTypeExtension {
158
273
pub position : Pos ,
159
274
pub name : Name ,
160
275
pub directives : Vec < Directive > ,
161
276
pub values : Vec < EnumValue > ,
162
277
}
163
278
164
- #[ derive( Debug , Clone , Default , PartialEq ) ]
279
+ impl EnumTypeExtension {
280
+ pub fn new ( name : Name ) -> Self {
281
+ Self {
282
+ position : Pos :: default ( ) ,
283
+ name,
284
+ directives : vec ! [ ] ,
285
+ values : vec ! [ ] ,
286
+ }
287
+ }
288
+ }
289
+
290
+ #[ derive( Debug , Clone , PartialEq ) ]
165
291
pub struct InputObjectType {
166
292
pub position : Pos ,
167
293
pub description : Option < String > ,
@@ -170,14 +296,37 @@ pub struct InputObjectType {
170
296
pub fields : Vec < InputValue > ,
171
297
}
172
298
173
- #[ derive( Debug , Clone , Default , PartialEq ) ]
299
+ impl InputObjectType {
300
+ pub fn new ( name : Name ) -> Self {
301
+ Self {
302
+ position : Pos :: default ( ) ,
303
+ description : None ,
304
+ name,
305
+ directives : vec ! [ ] ,
306
+ fields : vec ! [ ] ,
307
+ }
308
+ }
309
+ }
310
+
311
+ #[ derive( Debug , Clone , PartialEq ) ]
174
312
pub struct InputObjectTypeExtension {
175
313
pub position : Pos ,
176
314
pub name : Name ,
177
315
pub directives : Vec < Directive > ,
178
316
pub fields : Vec < InputValue > ,
179
317
}
180
318
319
+ impl InputObjectTypeExtension {
320
+ pub fn new ( name : Name ) -> Self {
321
+ Self {
322
+ position : Pos :: default ( ) ,
323
+ name,
324
+ directives : vec ! [ ] ,
325
+ fields : vec ! [ ] ,
326
+ }
327
+ }
328
+ }
329
+
181
330
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
182
331
pub enum DirectiveLocation {
183
332
// executable
@@ -203,7 +352,7 @@ pub enum DirectiveLocation {
203
352
InputFieldDefinition ,
204
353
}
205
354
206
- #[ derive( Debug , Clone , Default , PartialEq ) ]
355
+ #[ derive( Debug , Clone , PartialEq ) ]
207
356
pub struct DirectiveDefinition {
208
357
pub position : Pos ,
209
358
pub description : Option < String > ,
@@ -212,6 +361,18 @@ pub struct DirectiveDefinition {
212
361
pub locations : Vec < DirectiveLocation > ,
213
362
}
214
363
364
+ impl DirectiveDefinition {
365
+ pub fn new ( name : Name ) -> Self {
366
+ Self {
367
+ position : Pos :: default ( ) ,
368
+ description : None ,
369
+ name,
370
+ arguments : vec ! [ ] ,
371
+ locations : vec ! [ ] ,
372
+ }
373
+ }
374
+ }
375
+
215
376
impl DirectiveLocation {
216
377
/// Returns GraphQL syntax compatible name of the directive
217
378
pub fn as_str ( & self ) -> & ' static str {
0 commit comments