@@ -67,12 +67,20 @@ where
67
67
} ,
68
68
)
69
69
. map ( Selection :: InlineFragment )
70
- . or ( ( position ( ) , name :: < ' a , S > ( ) , parser ( directives) )
71
- . map ( |( position, fragment_name, directives) | FragmentSpread {
72
- position,
73
- fragment_name,
74
- directives,
75
- } )
70
+ . or ( (
71
+ position ( ) ,
72
+ name :: < ' a , S > ( ) ,
73
+ parser ( arguments) ,
74
+ parser ( directives) ,
75
+ )
76
+ . map (
77
+ |( position, fragment_name, arguments, directives) | FragmentSpread {
78
+ position,
79
+ fragment_name,
80
+ arguments,
81
+ directives,
82
+ } ,
83
+ )
76
84
. map ( Selection :: FragmentSpread ) ) ,
77
85
) )
78
86
. parse_stream ( input)
@@ -219,17 +227,41 @@ pub fn fragment_definition<'a, T: Text<'a>>(
219
227
(
220
228
position ( ) . skip ( ident ( "fragment" ) ) ,
221
229
name :: < ' a , T > ( ) ,
230
+ optional (
231
+ punct ( "(" )
232
+ . with ( many1 (
233
+ (
234
+ position ( ) ,
235
+ punct ( "$" ) . with ( name :: < ' a , T > ( ) ) . skip ( punct ( ":" ) ) ,
236
+ parser ( parse_type) ,
237
+ optional ( punct ( "=" ) . with ( parser ( default_value) ) ) ,
238
+ )
239
+ . map ( |( position, name, var_type, default_value) | {
240
+ VariableDefinition {
241
+ position,
242
+ name,
243
+ var_type,
244
+ default_value,
245
+ }
246
+ } ) ,
247
+ ) )
248
+ . skip ( punct ( ")" ) ) ,
249
+ )
250
+ . map ( |vars| vars. unwrap_or_default ( ) ) ,
222
251
ident ( "on" ) . with ( name :: < ' a , T > ( ) ) . map ( TypeCondition :: On ) ,
223
252
parser ( directives) ,
224
253
parser ( selection_set) ,
225
254
)
226
255
. map (
227
- |( position, name, type_condition, directives, selection_set) | FragmentDefinition {
228
- position,
229
- name,
230
- type_condition,
231
- directives,
232
- selection_set,
256
+ |( position, name, variable_definitions, type_condition, directives, selection_set) | {
257
+ FragmentDefinition {
258
+ position,
259
+ name,
260
+ variable_definitions,
261
+ type_condition,
262
+ directives,
263
+ selection_set,
264
+ }
233
265
} ,
234
266
)
235
267
. parse_stream ( input)
0 commit comments