libgraphql_core/operation/
mutation.rs1use crate::ast;
2use crate::types::GraphQLType;
3use crate::DirectiveAnnotation;
4use crate::loc;
5use crate::operation::FragmentRegistry;
6use crate::operation::MutationBuilder;
7use crate::operation::MutationBuildError;
8use crate::operation::OperationTrait;
9use crate::operation::OperationData;
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 Mutation<'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::Mutation,
27 MutationBuildError,
28 MutationBuilder<'schema, 'fragreg>,
29> for Mutation<'schema, 'fragreg> {
30 pub fn builder(
32 schema: &'schema Schema,
33 fragment_registry: &'fragreg FragmentRegistry<'schema>,
34 ) -> MutationBuilder<'schema, 'fragreg> {
35 MutationBuilder::new(schema, fragment_registry)
36 }
37
38 pub fn directives(&self) -> &Vec<DirectiveAnnotation> {
40 &self.0.directives
41 }
42
43 pub fn def_location(&self) -> &loc::SourceLocation {
46 &self.0.def_location
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.mutation_type().unwrap()
61 }
62
63 pub fn selection_set(&self) -> &SelectionSet<'fragreg> {
65 &self.0.selection_set
66 }
67
68 pub fn variables(&self) -> &IndexMap<String, Variable> {
70 &self.0.variables
71 }
72}