1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::common::OperationType;

impl<'a> super::SchemaDefinition<'a> {
    pub fn query_type(&self) -> Option<&'a str> {
        self.root_operations()
            .find(|operation| matches!(operation.operation_type(), OperationType::Query))
            .map(|operation| operation.named_type())
    }

    pub fn mutation_type(&self) -> Option<&'a str> {
        self.root_operations()
            .find(|operation| matches!(operation.operation_type(), OperationType::Mutation))
            .map(|operation| operation.named_type())
    }

    pub fn subscription_type(&self) -> Option<&'a str> {
        self.root_operations()
            .find(|operation| matches!(operation.operation_type(), OperationType::Subscription))
            .map(|operation| operation.named_type())
    }
}