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
28
use std::borrow::Cow;

use bytes::Bytes;

use crate::parser::types::Field;
use crate::parser::Positioned;
use crate::{registry, ContextSelectionSet, OutputType, ServerResult, Type, Value};

impl Type for Bytes {
    fn type_name() -> Cow<'static, str> {
        Cow::Borrowed("Binary")
    }

    fn create_type_info(registry: &mut registry::Registry) -> String {
        <String as Type>::create_type_info(registry)
    }
}

#[async_trait::async_trait]
impl OutputType for Bytes {
    async fn resolve(
        &self,
        _: &ContextSelectionSet<'_>,
        _field: &Positioned<Field>,
    ) -> ServerResult<Value> {
        Ok(Value::Binary(self.clone()))
    }
}