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
29
30
31
32
use async_graphql::dynamic;
use async_graphql::dynamic::Type;
use async_graphql::dynamic::ValueAccessor;
use async_graphql::Upload;
use std::borrow::Cow;

use crate::errors::InputValueResult;
use crate::from_value::FromValue;
use crate::registry::Registry;
use crate::types::InputTypeName;
use crate::types::Register;
use crate::types::TypeName;

impl TypeName for Upload {
    fn get_type_name() -> Cow<'static, str> {
        dynamic::TypeRef::UPLOAD.into()
    }
}

impl InputTypeName for Upload {}

impl FromValue for Upload {
    fn from_value(value: async_graphql::Result<ValueAccessor>) -> InputValueResult<Self> {
        Ok(value?.upload()?)
    }
}

impl Register for Upload {
    fn register(registry: Registry) -> Registry {
        registry.register_type(Type::Upload)
    }
}