diff --git a/src/look_ahead.rs b/src/look_ahead.rs index 68e56637..ccd874a8 100644 --- a/src/look_ahead.rs +++ b/src/look_ahead.rs @@ -54,6 +54,20 @@ impl<'a> Lookahead<'a> { pub fn exists(&self) -> bool { !self.fields.is_empty() } + + /// Get the `SelectionField`s for each of the fields covered by this `Lookahead`. + /// + /// There will be multiple fields in situations where the same field is queried twice. + pub fn selection_fields(&self) -> Vec> { + self.fields + .iter() + .map(|field| SelectionField { + fragments: self.fragments, + field, + context: self.context, + }) + .collect() + } } impl<'a> From> for Lookahead<'a> {