@@ -92,6 +92,7 @@ fn calculate_custom_response_type_selection<'a>(
9292 name : custom_response_type. as_str ( ) ,
9393 struct_id,
9494 boxed : false ,
95+ has_skip_or_include : false
9596 } ) ;
9697}
9798
@@ -128,7 +129,7 @@ pub(super) fn render_fragment<'a>(
128129/// A sub-selection set (spread) on one of the variants of a union or interface.
129130enum VariantSelection < ' a > {
130131 InlineFragment ( & ' a InlineFragment ) ,
131- FragmentSpread ( ( ResolvedFragmentId , & ' a ResolvedFragment ) ) ,
132+ FragmentSpread ( ( ResolvedFragmentId , & ' a ResolvedFragment ) , bool ) ,
132133}
133134
134135impl < ' a > VariantSelection < ' a > {
@@ -142,15 +143,15 @@ impl<'a> VariantSelection<'a> {
142143 Selection :: InlineFragment ( inline_fragment) => {
143144 Some ( VariantSelection :: InlineFragment ( inline_fragment) )
144145 }
145- Selection :: FragmentSpread ( fragment_id) => {
146+ Selection :: FragmentSpread ( fragment_id, has_skip_or_include ) => {
146147 let fragment = query. query . get_fragment ( * fragment_id) ;
147148
148149 if fragment. on == type_id {
149150 // The selection is on the type itself.
150151 None
151152 } else {
152153 // The selection is on one of the variants of the type.
153- Some ( VariantSelection :: FragmentSpread ( ( * fragment_id, fragment) ) )
154+ Some ( VariantSelection :: FragmentSpread ( ( * fragment_id, fragment) , * has_skip_or_include ) )
154155 }
155156 }
156157 Selection :: Field ( _) | Selection :: Typename => None ,
@@ -160,7 +161,7 @@ impl<'a> VariantSelection<'a> {
160161 fn variant_type_id ( & self ) -> TypeId {
161162 match self {
162163 VariantSelection :: InlineFragment ( f) => f. type_id ,
163- VariantSelection :: FragmentSpread ( ( _id, f) ) => f. on ,
164+ VariantSelection :: FragmentSpread ( ( _id, f) , _ ) => f. on ,
164165 }
165166 }
166167}
@@ -175,14 +176,15 @@ fn calculate_selection<'a>(
175176 // If the selection only contains a fragment, replace the selection with
176177 // that fragment.
177178 if selection_set. len ( ) == 1 {
178- if let Selection :: FragmentSpread ( fragment_id) =
179+ if let Selection :: FragmentSpread ( fragment_id, has_skip_or_include ) =
179180 context. query . query . get_selection ( selection_set[ 0 ] )
180181 {
181182 let fragment = context. query . query . get_fragment ( * fragment_id) ;
182183 context. push_type_alias ( TypeAlias {
183184 name : & fragment. name ,
184185 struct_id,
185186 boxed : fragment_is_recursive ( * fragment_id, context. query . query ) ,
187+ has_skip_or_include : * has_skip_or_include
186188 } ) ;
187189 return ;
188190 }
@@ -253,13 +255,14 @@ fn calculate_selection<'a>(
253255 let struct_id = context. push_type ( expanded_type) ;
254256
255257 if variant_selections. len ( ) == 1 {
256- if let VariantSelection :: FragmentSpread ( ( fragment_id, fragment) ) =
258+ if let VariantSelection :: FragmentSpread ( ( fragment_id, fragment) , has_skip_or_include ) =
257259 variant_selections[ 0 ] . 2
258260 {
259261 context. push_type_alias ( TypeAlias {
260262 boxed : fragment_is_recursive ( fragment_id, context. query . query ) ,
261263 name : & fragment. name ,
262264 struct_id,
265+ has_skip_or_include
263266 } ) ;
264267 continue ;
265268 }
@@ -276,7 +279,7 @@ fn calculate_selection<'a>(
276279 options,
277280 ) ;
278281 }
279- VariantSelection :: FragmentSpread ( ( fragment_id, fragment) ) => context
282+ VariantSelection :: FragmentSpread ( ( fragment_id, fragment) , has_skip_or_include ) => context
280283 . push_field ( ExpandedField {
281284 field_type : fragment. name . as_str ( ) . into ( ) ,
282285 field_type_qualifiers : & [ GraphqlTypeQualifier :: Required ] ,
@@ -286,8 +289,7 @@ fn calculate_selection<'a>(
286289 struct_id,
287290 deprecation : None ,
288291 boxed : fragment_is_recursive ( * fragment_id, context. query . query ) ,
289- // TODO
290- skip_or_include : false
292+ skip_or_include : * has_skip_or_include
291293 } ) ,
292294 }
293295 }
@@ -387,7 +389,7 @@ fn calculate_selection<'a>(
387389 }
388390 Selection :: Typename => ( ) ,
389391 Selection :: InlineFragment ( _inline) => ( ) ,
390- Selection :: FragmentSpread ( fragment_id) => {
392+ Selection :: FragmentSpread ( fragment_id, has_skip_or_include ) => {
391393 // Here we only render fragments that are directly on the type
392394 // itself, and not on one of its variants.
393395
@@ -413,7 +415,7 @@ fn calculate_selection<'a>(
413415 flatten : true ,
414416 deprecation : None ,
415417 boxed : fragment_is_recursive ( * fragment_id, context. query . query ) ,
416- skip_or_include : false
418+ skip_or_include : * has_skip_or_include
417419 } ) ;
418420
419421 // We stop here, because the structs for the fragments are generated separately, to
@@ -430,6 +432,7 @@ struct TypeAlias<'a> {
430432 name : & ' a str ,
431433 struct_id : ResponseTypeId ,
432434 boxed : bool ,
435+ has_skip_or_include : bool
433436}
434437
435438struct ExpandedField < ' a > {
0 commit comments