libgraphql_core/operation/
field_selection.rs

1use crate::types::Field;
2use crate::DirectiveAnnotation;
3use crate::loc;
4use crate::operation::SelectionSet;
5use crate::schema::Schema;
6use crate::Value;
7use indexmap::IndexMap;
8
9#[derive(Clone, Debug, PartialEq)]
10pub struct FieldSelection<'schema> {
11    pub(super) alias: Option<String>,
12    pub(super) arguments: IndexMap<String, Value>,
13    pub(super) def_location: loc::SourceLocation,
14    pub(super) directives: Vec<DirectiveAnnotation>,
15    pub(super) field: &'schema Field,
16    pub(super) schema: &'schema Schema,
17    pub(super) selection_set: Option<SelectionSet<'schema>>,
18}
19impl<'schema> FieldSelection<'schema> {
20    pub fn alias(&self) -> &Option<String> {
21        &self.alias
22    }
23
24    pub fn arguments(&self) -> &IndexMap<String, Value> {
25        &self.arguments
26    }
27
28    pub fn def_location(&self) -> &loc::SourceLocation {
29        &self.def_location
30    }
31
32    pub fn directives(&self) -> &Vec<DirectiveAnnotation> {
33        &self.directives
34    }
35
36    pub fn field(&self) -> &'schema Field {
37        self.field
38    }
39
40    pub fn selection_set(&self) -> Option<&SelectionSet<'schema>> {
41        self.selection_set.as_ref()
42    }
43}