libgraphql_parser/ast/
inline_fragment.rs1use crate::ast::ast_node::append_span_source_slice;
2use crate::ast::AstNode;
3use crate::ast::DirectiveAnnotation;
4use crate::ast::SelectionSet;
5use crate::ast::TypeCondition;
6use crate::ByteSpan;
7use crate::SourceMap;
8use crate::SourceSpan;
9use crate::token::GraphQLToken;
10use inherent::inherent;
11
12#[derive(Clone, Debug, PartialEq)]
19pub struct InlineFragment<'src> {
20 pub directives: Vec<DirectiveAnnotation<'src>>,
21 pub selection_set: SelectionSet<'src>,
22 pub span: ByteSpan,
23 pub syntax: Option<Box<InlineFragmentSyntax<'src>>>,
24 pub type_condition: Option<TypeCondition<'src>>,
25}
26
27#[derive(Clone, Debug, PartialEq)]
29pub struct InlineFragmentSyntax<'src> {
30 pub ellipsis: GraphQLToken<'src>,
31}
32
33#[inherent]
34impl AstNode for InlineFragment<'_> {
35 pub fn append_source(
37 &self,
38 sink: &mut String,
39 source: Option<&str>,
40 ) {
41 if let Some(src) = source {
42 append_span_source_slice(
43 self.span, sink, src,
44 );
45 }
46 }
47
48 #[inline]
55 pub fn byte_span(&self) -> ByteSpan {
56 self.span
57 }
58
59 #[inline]
66 pub fn source_span(
67 &self,
68 source_map: &SourceMap,
69 ) -> Option<SourceSpan> {
70 self.byte_span().resolve(source_map)
71 }
72}