libgraphql_core/operation/
subscription.rs1use crate::ast;
2use crate::operation::FragmentRegistry;
3use crate::types::GraphQLType;
4use crate::DirectiveAnnotation;
5use crate::loc;
6use crate::operation::OperationTrait;
7use crate::operation::OperationData;
8use crate::operation::SelectionSet;
9use crate::operation::SubscriptionBuilder;
10use crate::operation::SubscriptionBuildError;
11use crate::operation::Variable;
12use crate::schema::Schema;
13use indexmap::IndexMap;
14use inherent::inherent;
15
16#[derive(Clone, Debug, PartialEq)]
17pub struct Subscription<'schema: 'fragreg, 'fragreg>(
18 pub(super) OperationData<'schema, 'fragreg>,
19);
20
21#[inherent]
22impl<'schema: 'fragreg, 'fragreg> OperationTrait<
23 'schema,
24 'fragreg,
25 ast::operation::Subscription,
26 SubscriptionBuildError,
27 SubscriptionBuilder<'schema, 'fragreg>,
28> for Subscription<'schema, 'fragreg> {
29 pub fn builder(
31 schema: &'schema Schema,
32 fragment_registry: &'fragreg FragmentRegistry<'schema>,
33 ) -> SubscriptionBuilder<'schema, 'fragreg> {
34 SubscriptionBuilder::new(schema, fragment_registry)
35 }
36
37 pub fn directives(&self) -> &Vec<DirectiveAnnotation> {
39 &self.0.directives
40 }
41
42 pub fn def_location(&self) -> &loc::SourceLocation {
45 &self.0.def_location
46 }
47
48 pub fn name(&self) -> Option<&str> {
50 self.0.name.as_deref()
51 }
52
53 pub fn root_graphql_type(&self, schema: &'schema Schema) -> &GraphQLType {
56 schema.subscription_type().unwrap()
60 }
61
62 pub fn selection_set(&self) -> &SelectionSet<'fragreg> {
64 &self.0.selection_set
65 }
66
67 pub fn variables(&self) -> &IndexMap<String, Variable> {
69 &self.0.variables
70 }
71}