rusty_gql/resolver/
string.rs1use crate::{
2 CollectFields, Context, FieldResolver, GqlValue, ResolverResult, SelectionSetContext,
3 SelectionSetResolver,
4};
5
6#[async_trait::async_trait]
7impl FieldResolver for str {
8 async fn resolve_field(&self, _ctx: &Context<'_>) -> ResolverResult<Option<GqlValue>> {
9 Ok(Some(GqlValue::String(self.to_string())))
10 }
11 fn type_name() -> String {
12 "String".to_string()
13 }
14}
15
16impl CollectFields for str {}
17
18#[async_trait::async_trait]
19impl SelectionSetResolver for str {
20 async fn resolve_selection_set(
21 &self,
22 _ctx: &SelectionSetContext<'_>,
23 ) -> ResolverResult<GqlValue> {
24 Ok(GqlValue::String(self.to_string()))
25 }
26}
27
28#[async_trait::async_trait]
29impl FieldResolver for &str {
30 async fn resolve_field(&self, _ctx: &Context<'_>) -> ResolverResult<Option<GqlValue>> {
31 Ok(Some(GqlValue::String(self.to_string())))
32 }
33 fn type_name() -> String {
34 "String".to_string()
35 }
36}
37
38impl CollectFields for &str {}
39
40#[async_trait::async_trait]
41impl SelectionSetResolver for &str {
42 async fn resolve_selection_set(
43 &self,
44 _ctx: &SelectionSetContext<'_>,
45 ) -> ResolverResult<GqlValue> {
46 Ok(GqlValue::String(self.to_string()))
47 }
48}
49
50#[async_trait::async_trait]
51impl FieldResolver for String {
52 async fn resolve_field(&self, _ctx: &Context<'_>) -> ResolverResult<Option<GqlValue>> {
53 Ok(Some(GqlValue::String(self.clone())))
54 }
55 fn type_name() -> String {
56 "String".to_string()
57 }
58}
59
60impl CollectFields for String {}
61
62#[async_trait::async_trait]
63impl SelectionSetResolver for String {
64 async fn resolve_selection_set(
65 &self,
66 _ctx: &SelectionSetContext<'_>,
67 ) -> ResolverResult<GqlValue> {
68 Ok(GqlValue::String(self.clone()))
69 }
70}