async_graphql/model/
directive.rs1use std::collections::HashSet;
2
3use crate::{Enum, Object, model::__InputValue, registry};
4
5#[derive(Debug, Enum, Copy, Clone, Eq, PartialEq)]
8#[graphql(internal, name = "__DirectiveLocation")]
9#[allow(non_camel_case_types)]
10pub enum __DirectiveLocation {
11 QUERY,
13
14 MUTATION,
16
17 SUBSCRIPTION,
19
20 FIELD,
22
23 FRAGMENT_DEFINITION,
25
26 FRAGMENT_SPREAD,
28
29 INLINE_FRAGMENT,
31
32 VARIABLE_DEFINITION,
34
35 SCHEMA,
37
38 SCALAR,
40
41 OBJECT,
43
44 FIELD_DEFINITION,
46
47 ARGUMENT_DEFINITION,
49
50 INTERFACE,
52
53 UNION,
55
56 ENUM,
58
59 ENUM_VALUE,
61
62 INPUT_OBJECT,
64
65 INPUT_FIELD_DEFINITION,
67}
68
69#[doc(hidden)]
73#[allow(non_camel_case_types)]
74pub mod location_traits {
75 pub trait Directive_At_FIELD_DEFINITION {
76 fn check() {}
77 }
78
79 pub trait Directive_At_OBJECT {
80 fn check() {}
81 }
82
83 pub trait Directive_At_INPUT_FIELD_DEFINITION {
84 fn check() {}
85 }
86
87 pub trait Directive_At_ARGUMENT_DEFINITION {
88 fn check() {}
89 }
90
91 pub trait Directive_At_INPUT_OBJECT {
92 fn check() {}
93 }
94
95 pub trait Directive_At_INTERFACE {
96 fn check() {}
97 }
98
99 pub trait Directive_At_ENUM {
100 fn check() {}
101 }
102
103 pub trait Directive_At_ENUM_VALUE {
104 fn check() {}
105 }
106}
107
108pub struct __Directive<'a> {
109 pub registry: &'a registry::Registry,
110 pub visible_types: &'a HashSet<&'a str>,
111 pub directive: &'a registry::MetaDirective,
112}
113
114#[Object(internal, name = "__Directive")]
122impl<'a> __Directive<'a> {
123 #[inline]
124 async fn name(&self) -> &str {
125 &self.directive.name
126 }
127
128 #[inline]
129 async fn description(&self) -> Option<&str> {
130 self.directive.description.as_deref()
131 }
132
133 #[inline]
134 async fn locations(&self) -> &Vec<__DirectiveLocation> {
135 &self.directive.locations
136 }
137
138 async fn args(
139 &self,
140 #[graphql(default = false)] include_deprecated: bool,
141 ) -> Vec<__InputValue<'a>> {
142 self.directive
143 .args
144 .values()
145 .filter(|input_value| include_deprecated || !input_value.deprecation.is_deprecated())
146 .map(|input_value| __InputValue {
147 registry: self.registry,
148 visible_types: self.visible_types,
149 input_value,
150 })
151 .collect()
152 }
153
154 #[inline]
155 async fn is_repeatable(&self) -> bool {
156 self.directive.is_repeatable
157 }
158}