async_graphql/model/
input_value.rs

1use std::collections::HashSet;
2
3use crate::{model::__Type, registry, Object};
4
5pub struct __InputValue<'a> {
6    pub registry: &'a registry::Registry,
7    pub visible_types: &'a HashSet<&'a str>,
8    pub input_value: &'a registry::MetaInputValue,
9}
10
11/// Arguments provided to Fields or Directives and the input fields of an
12/// InputObject are represented as Input Values which describe their type and
13/// optionally a default value.
14#[Object(internal, name = "__InputValue")]
15impl<'a> __InputValue<'a> {
16    #[inline]
17    async fn name(&self) -> &str {
18        &self.input_value.name
19    }
20
21    #[inline]
22    async fn description(&self) -> Option<&str> {
23        self.input_value.description.as_deref()
24    }
25
26    #[graphql(name = "type")]
27    #[inline]
28    async fn ty(&self) -> __Type<'a> {
29        __Type::new(self.registry, self.visible_types, &self.input_value.ty)
30    }
31
32    #[inline]
33    async fn default_value(&self) -> Option<&str> {
34        self.input_value.default_value.as_deref()
35    }
36
37    #[inline]
38    async fn is_deprecated(&self) -> bool {
39        self.input_value.deprecation.is_deprecated()
40    }
41
42    #[inline]
43    async fn deprecation_reason(&self) -> Option<&str> {
44        self.input_value.deprecation.reason()
45    }
46}