libgraphql_core/operation/
fragment_spread.rs1use crate::DirectiveAnnotation;
2use crate::loc;
3use crate::operation::FragmentRegistry;
4use crate::operation::Fragment;
5use crate::operation::FragmentRef;
6
7#[derive(Clone, Debug, PartialEq)]
8pub struct FragmentSpread<'schema> {
9 pub(super) def_location: loc::SourceLocation,
10 pub(super) directives: Vec<DirectiveAnnotation>,
11 pub(super) fragment_ref: FragmentRef<'schema>,
12}
13impl<'schema> FragmentSpread<'schema> {
14 pub fn def_location(&self) -> &loc::SourceLocation {
15 &self.def_location
16 }
17
18 pub fn directives(&self) -> &Vec<DirectiveAnnotation> {
19 &self.directives
20 }
21
22 pub fn fragment<'fragreg: 'schema>(
23 &self,
24 fragment_registry: &'fragreg FragmentRegistry<'schema>,
25 ) -> &'fragreg Fragment<'schema> {
26 self.fragment_ref
27 .deref(fragment_registry)
28 .expect("fragment is present in the fragment set")
29 }
30
31 pub fn fragment_name(&self) -> &str {
32 self.fragment_ref.name()
33 }
34}