libgraphql_core/operation/
query.rs1use crate::ast;
2use crate::types::GraphQLType;
3use crate::DirectiveAnnotation;
4use crate::loc;
5use crate::operation::FragmentRegistry;
6use crate::operation::OperationTrait;
7use crate::operation::OperationData;
8use crate::operation::QueryBuilder;
9use crate::operation::QueryBuildError;
10use crate::operation::SelectionSet;
11use crate::operation::Variable;
12use crate::schema::Schema;
13use indexmap::IndexMap;
14use inherent::inherent;
15
16#[derive(Clone, Debug, PartialEq)]
18pub struct Query<'schema: 'fragreg, 'fragreg>(
19 pub(super) OperationData<'schema, 'fragreg>,
20);
21
22#[inherent]
23impl<'schema: 'fragreg, 'fragreg> OperationTrait<
24 'schema,
25 'fragreg,
26 ast::operation::Query,
27 QueryBuildError,
28 QueryBuilder<'schema, 'fragreg>,
29> for Query<'schema, 'fragreg> {
30 pub fn builder(
32 schema: &'schema Schema,
33 fragment_registry: &'fragreg FragmentRegistry<'schema>,
34 ) -> QueryBuilder<'schema, 'fragreg> {
35 QueryBuilder::new(schema, fragment_registry)
36 }
37
38 pub fn def_location(&self) -> &loc::SourceLocation {
41 &self.0.def_location
42 }
43
44 pub fn directives(&self) -> &Vec<DirectiveAnnotation> {
46 &self.0.directives
47 }
48
49 pub fn name(&self) -> Option<&str> {
51 self.0.name.as_deref()
52 }
53
54 pub fn root_graphql_type(&self, schema: &'schema Schema) -> &GraphQLType {
57 schema.query_type()
58 }
59
60 pub fn selection_set(&self) -> &SelectionSet<'fragreg> {
62 &self.0.selection_set
63 }
64
65 pub fn variables(&self) -> &IndexMap<String, Variable> {
67 &self.0.variables
68 }
69}