bluejay_core/definition/
schema_definition.rs

1use crate::definition::{
2    ArgumentsDefinition, Directive, DirectiveDefinition, Directives, EnumTypeDefinition,
3    EnumValueDefinition, EnumValueDefinitions, FieldDefinition, FieldsDefinition, HasDirectives,
4    InputFieldsDefinition, InputObjectTypeDefinition, InputType, InputValueDefinition,
5    InterfaceImplementation, InterfaceImplementations, InterfaceTypeDefinition,
6    ObjectTypeDefinition, OutputType, ScalarTypeDefinition, TypeDefinition,
7    TypeDefinitionReference, UnionMemberType, UnionMemberTypes, UnionTypeDefinition,
8};
9
10pub trait SchemaDefinition:
11    HasDirectives<Directives = <Self as SchemaDefinition>::Directives>
12{
13    type Directive: Directive<DirectiveDefinition = Self::DirectiveDefinition>;
14    type Directives: Directives<Directive = Self::Directive>;
15    type InputValueDefinition: InputValueDefinition<
16        InputType = Self::InputType,
17        Directives = <Self as SchemaDefinition>::Directives,
18    >;
19    type InputFieldsDefinition: InputFieldsDefinition<
20        InputValueDefinition = Self::InputValueDefinition,
21    >;
22    type ArgumentsDefinition: ArgumentsDefinition<ArgumentDefinition = Self::InputValueDefinition>;
23    type EnumValueDefinition: EnumValueDefinition<
24        Directives = <Self as SchemaDefinition>::Directives,
25    >;
26    type EnumValueDefinitions: EnumValueDefinitions<EnumValueDefinition = Self::EnumValueDefinition>;
27    type FieldDefinition: FieldDefinition<
28        ArgumentsDefinition = Self::ArgumentsDefinition,
29        OutputType = Self::OutputType,
30        Directives = <Self as SchemaDefinition>::Directives,
31    >;
32    type FieldsDefinition: FieldsDefinition<FieldDefinition = Self::FieldDefinition>;
33    type InterfaceImplementation: InterfaceImplementation<
34        InterfaceTypeDefinition = Self::InterfaceTypeDefinition,
35    >;
36    type InterfaceImplementations: InterfaceImplementations<
37        InterfaceImplementation = Self::InterfaceImplementation,
38    >;
39    type UnionMemberType: UnionMemberType<ObjectTypeDefinition = Self::ObjectTypeDefinition>;
40    type UnionMemberTypes: UnionMemberTypes<UnionMemberType = Self::UnionMemberType>;
41    type InputType: InputType<
42        CustomScalarTypeDefinition = Self::CustomScalarTypeDefinition,
43        InputObjectTypeDefinition = Self::InputObjectTypeDefinition,
44        EnumTypeDefinition = Self::EnumTypeDefinition,
45    >;
46    type OutputType: OutputType<
47        CustomScalarTypeDefinition = Self::CustomScalarTypeDefinition,
48        EnumTypeDefinition = Self::EnumTypeDefinition,
49        ObjectTypeDefinition = Self::ObjectTypeDefinition,
50        InterfaceTypeDefinition = Self::InterfaceTypeDefinition,
51        UnionTypeDefinition = Self::UnionTypeDefinition,
52    >;
53    type CustomScalarTypeDefinition: ScalarTypeDefinition<
54        Directives = <Self as SchemaDefinition>::Directives,
55    >;
56    type ObjectTypeDefinition: ObjectTypeDefinition<
57        FieldsDefinition = Self::FieldsDefinition,
58        InterfaceImplementations = Self::InterfaceImplementations,
59        Directives = <Self as SchemaDefinition>::Directives,
60    >;
61    type InterfaceTypeDefinition: InterfaceTypeDefinition<
62        FieldsDefinition = Self::FieldsDefinition,
63        InterfaceImplementations = Self::InterfaceImplementations,
64        Directives = <Self as SchemaDefinition>::Directives,
65    >;
66    type UnionTypeDefinition: UnionTypeDefinition<
67        UnionMemberTypes = Self::UnionMemberTypes,
68        Directives = <Self as SchemaDefinition>::Directives,
69        FieldsDefinition = Self::FieldsDefinition,
70    >;
71    type InputObjectTypeDefinition: InputObjectTypeDefinition<
72        InputFieldsDefinition = Self::InputFieldsDefinition,
73        Directives = <Self as SchemaDefinition>::Directives,
74    >;
75    type EnumTypeDefinition: EnumTypeDefinition<
76        Directives = <Self as SchemaDefinition>::Directives,
77        EnumValueDefinitions = Self::EnumValueDefinitions,
78    >;
79    type TypeDefinition: TypeDefinition<
80        CustomScalarTypeDefinition = Self::CustomScalarTypeDefinition,
81        ObjectTypeDefinition = Self::ObjectTypeDefinition,
82        InputObjectTypeDefinition = Self::InputObjectTypeDefinition,
83        EnumTypeDefinition = Self::EnumTypeDefinition,
84        UnionTypeDefinition = Self::UnionTypeDefinition,
85        InterfaceTypeDefinition = Self::InterfaceTypeDefinition,
86    >;
87    type DirectiveDefinition: DirectiveDefinition<ArgumentsDefinition = Self::ArgumentsDefinition>;
88    type TypeDefinitions<'a>: Iterator<Item = TypeDefinitionReference<'a, Self::TypeDefinition>>
89    where
90        Self: 'a;
91    type DirectiveDefinitions<'a>: Iterator<Item = &'a Self::DirectiveDefinition>
92    where
93        Self: 'a;
94    type InterfaceImplementors<'a>: Iterator<Item = &'a Self::ObjectTypeDefinition>
95    where
96        Self: 'a;
97
98    fn description(&self) -> Option<&str>;
99    fn query(&self) -> &Self::ObjectTypeDefinition;
100    fn mutation(&self) -> Option<&Self::ObjectTypeDefinition>;
101    fn subscription(&self) -> Option<&Self::ObjectTypeDefinition>;
102    fn get_type_definition(
103        &self,
104        name: &str,
105    ) -> Option<TypeDefinitionReference<Self::TypeDefinition>>;
106    fn type_definitions(&self) -> Self::TypeDefinitions<'_>;
107    fn get_directive_definition(&self, name: &str) -> Option<&Self::DirectiveDefinition>;
108    fn directive_definitions(&self) -> Self::DirectiveDefinitions<'_>;
109    fn get_interface_implementors(
110        &self,
111        itd: &Self::InterfaceTypeDefinition,
112    ) -> Self::InterfaceImplementors<'_>;
113}