forked from async-graphql/async-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenum_value.rs
27 lines (22 loc) · 814 Bytes
/
enum_value.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use crate::registry;
use async_graphql_derive::Object;
pub struct __EnumValue<'a> {
pub registry: &'a registry::Registry,
pub value: &'a registry::MetaEnumValue,
}
/// One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.
#[Object(internal)]
impl<'a> __EnumValue<'a> {
async fn name(&self) -> String {
self.value.name.to_string()
}
async fn description(&self) -> Option<String> {
self.value.description.map(|s| s.to_string())
}
async fn is_deprecated(&self) -> bool {
self.value.deprecation.is_some()
}
async fn deprecation_reason(&self) -> Option<String> {
self.value.deprecation.map(|s| s.to_string())
}
}