From 03f6ed4ba2790299327b2144ab1892ee5bd3d252 Mon Sep 17 00:00:00 2001 From: Sunli Date: Fri, 11 Dec 2020 15:37:50 +0800 Subject: [PATCH] Rename InputValueType to InputType and OutputValueType to OutputType. --- ARCHITECTURE.md | 8 ++++---- derive/src/enum.rs | 4 ++-- derive/src/input_object.rs | 14 +++++++------- derive/src/interface.rs | 6 +++--- derive/src/merged_object.rs | 2 +- derive/src/object.rs | 16 ++++++++-------- derive/src/scalar.rs | 4 ++-- derive/src/simple_object.rs | 4 ++-- derive/src/subscription.rs | 6 +++--- derive/src/union.rs | 2 +- src/base.rs | 10 +++++----- src/context.rs | 8 ++++---- src/error.rs | 8 ++++---- src/lib.rs | 4 ++-- src/resolver_utils/container.rs | 7 +++---- src/resolver_utils/enum.rs | 8 ++++---- src/resolver_utils/list.rs | 10 ++++------ src/resolver_utils/mod.rs | 2 +- src/resolver_utils/scalar.rs | 4 ++-- src/types/connection/connection_type.rs | 16 ++++++++-------- src/types/connection/edge.rs | 16 ++++++++-------- src/types/empty_mutation.rs | 4 ++-- src/types/external/cow.rs | 8 +++----- src/types/external/json_object/btreemap.rs | 5 ++--- src/types/external/json_object/hashmap.rs | 5 ++--- src/types/external/list/btree_set.rs | 16 +++++++--------- src/types/external/list/hash_set.rs | 16 +++++++--------- src/types/external/list/linked_list.rs | 17 ++++++++--------- src/types/external/list/slice.rs | 6 ++---- src/types/external/list/vec.rs | 14 +++++++------- src/types/external/list/vec_deque.rs | 17 ++++++++--------- src/types/external/optional.rs | 10 +++++----- src/types/external/string.rs | 4 ++-- src/types/json.rs | 8 ++++---- src/types/maybe_undefined.rs | 4 ++-- src/types/merged_object.rs | 6 +++--- src/types/query_root.rs | 12 ++++++------ src/types/upload.rs | 4 ++-- 38 files changed, 150 insertions(+), 165 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 1665bf87..e09b5fac 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -28,9 +28,9 @@ which keeps track of how deeply nested the query gets as the document is walked At this point all the unnecessary operations (ones not selected by `operationName`) are dropped, and we will execute just one. -At the core of all the resolver logic there are two traits: `InputValueType` and `OutputValueType` -which represent a GraphQL input value and GraphQL output value respectively. `InputValueType` just -requires conversions to and from `async_graphql::Value`. `OutputValueType` is an async trait with a +At the core of all the resolver logic there are two traits: `InputType` and `OutputType` +which represent a GraphQL input value and GraphQL output value respectively. `InputType` just +requires conversions to and from `async_graphql::Value`. `OutputType` is an async trait with a single method, `resolve`, which takes a field (e.g. `user(name: "sunli829") { display_name }`) and resolves it to a single value. @@ -38,5 +38,5 @@ Scalars and enums are expected to ignore the input and serialize themselves, whi interfaces and unions are expected to read the selection set in the field and resolve and serialize each one of their fields. -As implementing `OutputValueType::resolve` manually quickly becomes very tedious helpful utilities +As implementing `OutputType::resolve` manually quickly becomes very tedious helpful utilities are provided in the `resolver_utils` module and via macros. diff --git a/derive/src/enum.rs b/derive/src/enum.rs index f11f9ebe..49626b56 100644 --- a/derive/src/enum.rs +++ b/derive/src/enum.rs @@ -149,7 +149,7 @@ pub fn generate(enum_args: &args::Enum) -> GeneratorResult { } #[allow(clippy::all, clippy::pedantic)] - impl #crate_name::InputValueType for #ident { + impl #crate_name::InputType for #ident { fn parse(value: ::std::option::Option<#crate_name::Value>) -> #crate_name::InputValueResult { #crate_name::resolver_utils::parse_enum(value.unwrap_or_default()) } @@ -160,7 +160,7 @@ pub fn generate(enum_args: &args::Enum) -> GeneratorResult { } #[#crate_name::async_trait::async_trait] - impl #crate_name::OutputValueType for #ident { + impl #crate_name::OutputType for #ident { async fn resolve(&self, _: &#crate_name::ContextSelectionSet<'_>, _field: &#crate_name::Positioned<#crate_name::parser::types::Field>) -> #crate_name::ServerResult<#crate_name::Value> { ::std::result::Result::Ok(#crate_name::resolver_utils::enum_value(*self)) } diff --git a/derive/src/input_object.rs b/derive/src/input_object.rs index 2cc216a3..059de46b 100644 --- a/derive/src/input_object.rs +++ b/derive/src/input_object.rs @@ -74,7 +74,7 @@ pub fn generate(object_args: &args::InputObject) -> GeneratorResult }); get_fields.push(quote! { - let #ident: #ty = #crate_name::InputValueType::parse( + let #ident: #ty = #crate_name::InputType::parse( ::std::option::Option::Some(#crate_name::Value::Object(::std::clone::Clone::clone(&obj))) ).map_err(#crate_name::InputValueError::propagate)?; }); @@ -82,7 +82,7 @@ pub fn generate(object_args: &args::InputObject) -> GeneratorResult fields.push(ident); put_fields.push(quote! { - if let #crate_name::Value::Object(values) = #crate_name::InputValueType::to_value(&self.#ident) { + if let #crate_name::Value::Object(values) = #crate_name::InputType::to_value(&self.#ident) { map.extend(values); } }); @@ -105,7 +105,7 @@ pub fn generate(object_args: &args::InputObject) -> GeneratorResult .map(|value| { quote! { ::std::option::Option::Some(::std::string::ToString::to_string( - &<#ty as #crate_name::InputValueType>::to_value(&#value) + &<#ty as #crate_name::InputType>::to_value(&#value) )) } }) @@ -117,7 +117,7 @@ pub fn generate(object_args: &args::InputObject) -> GeneratorResult let #ident: #ty = { match obj.get(#name) { ::std::option::Option::Some(value) => { - #crate_name::InputValueType::parse(::std::option::Option::Some(::std::clone::Clone::clone(&value))) + #crate_name::InputType::parse(::std::option::Option::Some(::std::clone::Clone::clone(&value))) .map_err(#crate_name::InputValueError::propagate)? }, ::std::option::Option::None => #default, @@ -127,7 +127,7 @@ pub fn generate(object_args: &args::InputObject) -> GeneratorResult } else { get_fields.push(quote! { #[allow(non_snake_case)] - let #ident: #ty = #crate_name::InputValueType::parse(obj.get(#name).cloned()) + let #ident: #ty = #crate_name::InputType::parse(obj.get(#name).cloned()) .map_err(#crate_name::InputValueError::propagate)?; }); } @@ -135,7 +135,7 @@ pub fn generate(object_args: &args::InputObject) -> GeneratorResult put_fields.push(quote! { map.insert( #crate_name::Name::new(#name), - #crate_name::InputValueType::to_value(&self.#ident) + #crate_name::InputType::to_value(&self.#ident) ); }); @@ -180,7 +180,7 @@ pub fn generate(object_args: &args::InputObject) -> GeneratorResult } #[allow(clippy::all, clippy::pedantic)] - impl #crate_name::InputValueType for #ident { + impl #crate_name::InputType for #ident { fn parse(value: ::std::option::Option<#crate_name::Value>) -> #crate_name::InputValueResult { if let ::std::option::Option::Some(#crate_name::Value::Object(obj)) = value { #(#get_fields)* diff --git a/derive/src/interface.rs b/derive/src/interface.rs index 07b65343..82cead19 100644 --- a/derive/src/interface.rs +++ b/derive/src/interface.rs @@ -210,7 +210,7 @@ pub fn generate(interface_args: &args::Interface) -> GeneratorResult::to_value(&#value) + &<#ty as #crate_name::InputType>::to_value(&#value) )) } }) @@ -285,7 +285,7 @@ pub fn generate(interface_args: &args::Interface) -> GeneratorResult GeneratorResult, _field: &#crate_name::Positioned<#crate_name::parser::types::Field>) -> #crate_name::ServerResult<#crate_name::Value> { #crate_name::resolver_utils::resolve_container(ctx, self).await } diff --git a/derive/src/merged_object.rs b/derive/src/merged_object.rs index 77305d61..6d17519d 100644 --- a/derive/src/merged_object.rs +++ b/derive/src/merged_object.rs @@ -102,7 +102,7 @@ pub fn generate(object_args: &args::MergedObject) -> GeneratorResult, _field: &#crate_name::Positioned<#crate_name::parser::types::Field>) -> #crate_name::ServerResult<#crate_name::Value> { #crate_name::resolver_utils::resolve_container(ctx, self).await } diff --git a/derive/src/object.rs b/derive/src/object.rs index 406f409c..94dea791 100644 --- a/derive/src/object.rs +++ b/derive/src/object.rs @@ -95,7 +95,7 @@ pub fn generate( { return Err(Error::new_spanned( arg, - "Only types that implement `InputValueType` can be used as input arguments.", + "Only types that implement `InputType` can be used as input arguments.", ) .into()); } else { @@ -152,7 +152,7 @@ pub fn generate( }); key_getter.push(quote! { params.get(#name).and_then(|value| { - let value: ::std::option::Option<#ty> = #crate_name::InputValueType::parse(::std::option::Option::Some(::std::clone::Clone::clone(&value))).ok(); + let value: ::std::option::Option<#ty> = #crate_name::InputType::parse(::std::option::Option::Some(::std::clone::Clone::clone(&value))).ok(); value }) }); @@ -161,7 +161,7 @@ pub fn generate( } else { // requires requires_getter.push(quote! { - let #ident: #ty = #crate_name::InputValueType::parse(params.get(#name).cloned()). + let #ident: #ty = #crate_name::InputType::parse(params.get(#name).cloned()). map_err(|err| err.into_server_error().at(ctx.item.pos))?; }); use_keys.push(ident); @@ -197,7 +197,7 @@ pub fn generate( if let (#(#key_pat),*) = (#(#key_getter),*) { #(#requires_getter)* let ctx_obj = ctx.with_selection_set(&ctx.item.node.selection_set); - return #crate_name::OutputValueType::resolve(&#do_find, &ctx_obj, ctx.item).await.map(::std::option::Option::Some); + return #crate_name::OutputType::resolve(&#do_find, &ctx_obj, ctx.item).await.map(::std::option::Option::Some); } } }, @@ -285,7 +285,7 @@ pub fn generate( { return Err(Error::new_spanned( arg, - "Only types that implement `InputValueType` can be used as input arguments.", + "Only types that implement `InputType` can be used as input arguments.", ) .into()); } @@ -338,7 +338,7 @@ pub fn generate( .map(|value| { quote! { ::std::option::Option::Some(::std::string::ToString::to_string( - &<#ty as #crate_name::InputValueType>::to_value(&#value) + &<#ty as #crate_name::InputType>::to_value(&#value) )) } }) @@ -442,7 +442,7 @@ pub fn generate( #guard let ctx_obj = ctx.with_selection_set(&ctx.item.node.selection_set); let res = #resolve_obj; - return #crate_name::OutputValueType::resolve(&res, &ctx_obj, ctx.item).await.map(::std::option::Option::Some); + return #crate_name::OutputType::resolve(&res, &ctx_obj, ctx.item).await.map(::std::option::Option::Some); } }); } @@ -530,7 +530,7 @@ pub fn generate( #[allow(clippy::all, clippy::pedantic)] #[#crate_name::async_trait::async_trait] - impl #generics #crate_name::OutputValueType for #self_ty #where_clause { + impl #generics #crate_name::OutputType for #self_ty #where_clause { async fn resolve(&self, ctx: &#crate_name::ContextSelectionSet<'_>, _field: &#crate_name::Positioned<#crate_name::parser::types::Field>) -> #crate_name::ServerResult<#crate_name::Value> { #crate_name::resolver_utils::resolve_container(ctx, self).await } diff --git a/derive/src/scalar.rs b/derive/src/scalar.rs index 5ec84b0e..8d18af08 100644 --- a/derive/src/scalar.rs +++ b/derive/src/scalar.rs @@ -46,7 +46,7 @@ pub fn generate( } #[allow(clippy::all, clippy::pedantic)] - impl #generic #crate_name::InputValueType for #self_ty #where_clause { + impl #generic #crate_name::InputType for #self_ty #where_clause { fn parse(value: ::std::option::Option<#crate_name::Value>) -> #crate_name::InputValueResult { <#self_ty as #crate_name::ScalarType>::parse(value.unwrap_or_default()) } @@ -58,7 +58,7 @@ pub fn generate( #[allow(clippy::all, clippy::pedantic)] #[#crate_name::async_trait::async_trait] - impl #generic #crate_name::OutputValueType for #self_ty #where_clause { + impl #generic #crate_name::OutputType for #self_ty #where_clause { async fn resolve( &self, _: &#crate_name::ContextSelectionSet<'_>, diff --git a/derive/src/simple_object.rs b/derive/src/simple_object.rs index 5f7f4d35..55d79364 100644 --- a/derive/src/simple_object.rs +++ b/derive/src/simple_object.rs @@ -124,7 +124,7 @@ pub fn generate(object_args: &args::SimpleObject) -> GeneratorResult GeneratorResult, _field: &#crate_name::Positioned<#crate_name::parser::types::Field>) -> #crate_name::ServerResult<#crate_name::Value> { #crate_name::resolver_utils::resolve_container(ctx, self).await } diff --git a/derive/src/subscription.rs b/derive/src/subscription.rs index becb4f68..c0233d51 100644 --- a/derive/src/subscription.rs +++ b/derive/src/subscription.rs @@ -115,7 +115,7 @@ pub fn generate( { return Err(Error::new_spanned( arg, - "Only types that implement `InputValueType` can be used as input arguments.", + "Only types that implement `InputType` can be used as input arguments.", ) .into()); } else { @@ -177,7 +177,7 @@ pub fn generate( .map(|value| { quote! { ::std::option::Option::Some(::std::string::ToString::to_string( - &<#ty as #crate_name::InputValueType>::to_value(&#value) + &<#ty as #crate_name::InputType>::to_value(&#value) )) } }) @@ -319,7 +319,7 @@ pub fn generate( query_env.extensions.resolve_start(&ctx_extension, &ri); - let res = #crate_name::OutputValueType::resolve(&msg, &ctx_selection_set, &*field).await; + let res = #crate_name::OutputType::resolve(&msg, &ctx_selection_set, &*field).await; query_env.extensions.resolve_end(&ctx_extension, &ri); query_env.extensions.execution_end(&ctx_extension); diff --git a/derive/src/union.rs b/derive/src/union.rs index fe825499..40d94b67 100644 --- a/derive/src/union.rs +++ b/derive/src/union.rs @@ -197,7 +197,7 @@ pub fn generate(union_args: &args::Union) -> GeneratorResult { #[allow(clippy::all, clippy::pedantic)] #[#crate_name::async_trait::async_trait] - impl #generics #crate_name::OutputValueType for #ident #generics { + impl #generics #crate_name::OutputType for #ident #generics { async fn resolve(&self, ctx: &#crate_name::ContextSelectionSet<'_>, _field: &#crate_name::Positioned<#crate_name::parser::types::Field>) -> #crate_name::ServerResult<#crate_name::Value> { #crate_name::resolver_utils::resolve_container(ctx, self).await } diff --git a/src/base.rs b/src/base.rs index ab83ad62..a19fd3ec 100644 --- a/src/base.rs +++ b/src/base.rs @@ -36,7 +36,7 @@ pub trait Type { } /// Represents a GraphQL input value. -pub trait InputValueType: Type + Sized { +pub trait InputType: Type + Sized { /// Parse from `Value`. None represents undefined. fn parse(value: Option) -> InputValueResult; @@ -46,7 +46,7 @@ pub trait InputValueType: Type + Sized { /// Represents a GraphQL output value. #[async_trait::async_trait] -pub trait OutputValueType: Type { +pub trait OutputType: Type { /// Resolve an output value to `async_graphql::Value`. async fn resolve( &self, @@ -66,7 +66,7 @@ impl Type for &T { } #[async_trait::async_trait] -impl OutputValueType for &T { +impl OutputType for &T { #[allow(clippy::trivially_copy_pass_by_ref)] async fn resolve( &self, @@ -92,7 +92,7 @@ impl Type for Result { } #[async_trait::async_trait] -impl OutputValueType for Result { +impl OutputType for Result { async fn resolve( &self, ctx: &ContextSelectionSet<'_>, @@ -118,4 +118,4 @@ pub trait InterfaceType: ContainerType {} pub trait UnionType: ContainerType {} /// A GraphQL input object. -pub trait InputObjectType: InputValueType {} +pub trait InputObjectType: InputType {} diff --git a/src/context.rs b/src/context.rs index 2bc53e72..957cd3d6 100644 --- a/src/context.rs +++ b/src/context.rs @@ -20,7 +20,7 @@ use crate::parser::types::{ }; use crate::schema::SchemaEnv; use crate::{ - Error, InputValueType, Lookahead, Name, Pos, Positioned, Result, ServerError, ServerResult, + Error, InputType, Lookahead, Name, Pos, Positioned, Result, ServerError, ServerResult, UploadValue, Value, }; @@ -493,7 +493,7 @@ impl<'a, T> ContextBase<'a, T> { let condition_input = self.resolve_input_value(condition_input)?; if include - != ::parse(Some(condition_input)) + != ::parse(Some(condition_input)) .map_err(|e| e.into_server_error().at(pos))? { return Ok(true); @@ -523,7 +523,7 @@ impl<'a> ContextBase<'a, &'a Positioned> { impl<'a> ContextBase<'a, &'a Positioned> { #[doc(hidden)] - pub fn param_value( + pub fn param_value( &self, name: &str, default: Option T>, @@ -538,7 +538,7 @@ impl<'a> ContextBase<'a, &'a Positioned> { Some(value) => (value.pos, Some(self.resolve_input_value(value)?)), None => (Pos::default(), None), }; - InputValueType::parse(value).map_err(|e| e.into_server_error().at(pos)) + InputType::parse(value).map_err(|e| e.into_server_error().at(pos)) } /// Creates a uniform interface to inspect the forthcoming selections. diff --git a/src/error.rs b/src/error.rs index 2a0ea2ad..a11c1a4a 100644 --- a/src/error.rs +++ b/src/error.rs @@ -5,7 +5,7 @@ use std::marker::PhantomData; use serde::{Deserialize, Serialize}; use thiserror::Error; -use crate::{parser, InputValueType, Pos, Value}; +use crate::{parser, InputType, Pos, Value}; /// Extensions to the error. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)] @@ -117,7 +117,7 @@ pub struct InputValueError { phantom: PhantomData, } -impl InputValueError { +impl InputValueError { fn new(message: String) -> Self { Self { message, @@ -145,7 +145,7 @@ impl InputValueError { } /// Propagate the error message to a different type. - pub fn propagate(self) -> InputValueError { + pub fn propagate(self) -> InputValueError { if T::type_name() != U::type_name() { InputValueError::new(format!( r#"{} (occurred while parsing "{}")"#, @@ -163,7 +163,7 @@ impl InputValueError { } } -impl From for InputValueError { +impl From for InputValueError { fn from(error: E) -> Self { Self::custom(error) } diff --git a/src/lib.rs b/src/lib.rs index 185e2f02..97096a23 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -69,6 +69,7 @@ //! - `chrono-tz`: Integrate with the [`chrono-tz` crate](https://crates.io/crates/chrono-tz). //! - `url`: Integrate with the [`url` crate](https://crates.io/crates/url). //! - `uuid`: Integrate with the [`uuid` crate](https://crates.io/crates/uuid). +//! - `string_number`: Enable the [StringNumber](extensions/types.StringNumber.html). //! //! ## Integrations //! @@ -199,8 +200,7 @@ pub use async_graphql_value::{ SerializerError, }; pub use base::{ - Description, InputObjectType, InputValueType, InterfaceType, ObjectType, OutputValueType, Type, - UnionType, + Description, InputObjectType, InputType, InterfaceType, ObjectType, OutputType, Type, UnionType, }; pub use error::{ Error, ErrorExtensionValues, ErrorExtensions, InputValueError, InputValueResult, diff --git a/src/resolver_utils/container.rs b/src/resolver_utils/container.rs index a3471689..c32e54fb 100644 --- a/src/resolver_utils/container.rs +++ b/src/resolver_utils/container.rs @@ -6,16 +6,15 @@ use crate::extensions::{ErrorLogger, ExtensionContext, ResolveInfo}; use crate::parser::types::Selection; use crate::registry::MetaType; use crate::{ - Context, ContextSelectionSet, Name, OutputValueType, PathSegment, ServerError, ServerResult, - Value, + Context, ContextSelectionSet, Name, OutputType, PathSegment, ServerError, ServerResult, Value, }; /// Represents a GraphQL container object. /// /// This helper trait allows the type to call `resolve_container` on itself in its -/// `OutputValueType::resolve` implementation. +/// `OutputType::resolve` implementation. #[async_trait::async_trait] -pub trait ContainerType: OutputValueType { +pub trait ContainerType: OutputType { /// This function returns true of type `EmptyMutation` only. #[doc(hidden)] fn is_empty() -> bool { diff --git a/src/resolver_utils/enum.rs b/src/resolver_utils/enum.rs index 1d66e0a1..5fa47566 100644 --- a/src/resolver_utils/enum.rs +++ b/src/resolver_utils/enum.rs @@ -1,4 +1,4 @@ -use crate::{InputValueError, InputValueResult, InputValueType, Name, Type, Value}; +use crate::{InputType, InputValueError, InputValueResult, Name, Type, Value}; /// A variant of an enum. pub struct EnumItem { @@ -16,8 +16,8 @@ pub trait EnumType: Type + Sized + Eq + Send + Copy + Sized + 'static { /// Parse a value as an enum value. /// -/// This can be used to implement `InputValueType::parse`. -pub fn parse_enum(value: Value) -> InputValueResult { +/// This can be used to implement `InputType::parse`. +pub fn parse_enum(value: Value) -> InputValueResult { let value = match &value { Value::Enum(s) => s, Value::String(s) => s.as_str(), @@ -38,7 +38,7 @@ pub fn parse_enum(value: Value) -> InputValueResul /// Convert the enum value into a GraphQL value. /// -/// This can be used to implement `InputValueType::to_value` or `OutputValueType::resolve`. +/// This can be used to implement `InputType::to_value` or `OutputType::resolve`. pub fn enum_value(value: T) -> Value { let item = T::items().iter().find(|item| item.value == value).unwrap(); Value::Enum(Name::new(item.name)) diff --git a/src/resolver_utils/list.rs b/src/resolver_utils/list.rs index 03f48f86..c136cbbc 100644 --- a/src/resolver_utils/list.rs +++ b/src/resolver_utils/list.rs @@ -1,11 +1,9 @@ use crate::extensions::{ErrorLogger, ExtensionContext, ResolveInfo}; use crate::parser::types::Field; -use crate::{ - ContextSelectionSet, OutputValueType, PathSegment, Positioned, ServerResult, Type, Value, -}; +use crate::{ContextSelectionSet, OutputType, PathSegment, Positioned, ServerResult, Type, Value}; /// Resolve an list by executing each of the items concurrently. -pub async fn resolve_list<'a, T: OutputValueType + Send + Sync + 'a>( +pub async fn resolve_list<'a, T: OutputType + Send + Sync + 'a>( ctx: &ContextSelectionSet<'a>, field: &Positioned, iter: impl IntoIterator, @@ -22,7 +20,7 @@ pub async fn resolve_list<'a, T: OutputValueType + Send + Sync + 'a>( }; if ctx_idx.query_env.extensions.is_empty() { - OutputValueType::resolve(&item, &ctx_idx, field) + OutputType::resolve(&item, &ctx_idx, field) .await .map_err(|e| e.path(PathSegment::Index(idx))) .log_error(&ctx_extension, &ctx_idx.query_env.extensions) @@ -39,7 +37,7 @@ pub async fn resolve_list<'a, T: OutputValueType + Send + Sync + 'a>( .extensions .resolve_start(&ctx_extension, &resolve_info); - let res = OutputValueType::resolve(&item, &ctx_idx, field) + let res = OutputType::resolve(&item, &ctx_idx, field) .await .map_err(|e| e.path(PathSegment::Index(idx))) .log_error(&ctx_extension, &ctx_idx.query_env.extensions)?; diff --git a/src/resolver_utils/mod.rs b/src/resolver_utils/mod.rs index 4c2b5a27..50160573 100644 --- a/src/resolver_utils/mod.rs +++ b/src/resolver_utils/mod.rs @@ -1,5 +1,5 @@ //! Utilities for implementing -//! [`OutputValueType::resolve`](trait.OutputValueType.html#tymethod.resolve). +//! [`OutputType::resolve`](trait.OutputType.html#tymethod.resolve). mod container; mod r#enum; diff --git a/src/resolver_utils/scalar.rs b/src/resolver_utils/scalar.rs index e95de8d8..6899fcf4 100644 --- a/src/resolver_utils/scalar.rs +++ b/src/resolver_utils/scalar.rs @@ -135,7 +135,7 @@ macro_rules! scalar_internal { } } - impl $crate::InputValueType for $ty { + impl $crate::InputType for $ty { fn parse( value: ::std::option::Option<$crate::Value>, ) -> $crate::InputValueResult { @@ -148,7 +148,7 @@ macro_rules! scalar_internal { } #[$crate::async_trait::async_trait] - impl $crate::OutputValueType for $ty { + impl $crate::OutputType for $ty { async fn resolve( &self, _: &$crate::ContextSelectionSet<'_>, diff --git a/src/types/connection/connection_type.rs b/src/types/connection/connection_type.rs index e837b50b..7ce2d3e5 100644 --- a/src/types/connection/connection_type.rs +++ b/src/types/connection/connection_type.rs @@ -9,7 +9,7 @@ use crate::parser::types::Field; use crate::resolver_utils::{resolve_container, ContainerType}; use crate::types::connection::{CursorType, EmptyFields}; use crate::{ - registry, Context, ContextSelectionSet, ObjectType, OutputValueType, Positioned, Result, + registry, Context, ContextSelectionSet, ObjectType, OutputType, Positioned, Result, ServerResult, Type, Value, }; @@ -122,7 +122,7 @@ impl Connection { impl Type for Connection where C: CursorType, - T: OutputValueType + Send + Sync, + T: OutputType + Send + Sync, EC: ObjectType + Sync + Send, EE: ObjectType + Sync + Send, { @@ -194,7 +194,7 @@ where impl ContainerType for Connection where C: CursorType + Send + Sync, - T: OutputValueType + Send + Sync, + T: OutputType + Send + Sync, EC: ObjectType + Sync + Send, EE: ObjectType + Sync + Send, { @@ -207,12 +207,12 @@ where end_cursor: self.edges.last().map(|edge| edge.cursor.encode_cursor()), }; let ctx_obj = ctx.with_selection_set(&ctx.item.node.selection_set); - return OutputValueType::resolve(&page_info, &ctx_obj, ctx.item) + return OutputType::resolve(&page_info, &ctx_obj, ctx.item) .await .map(Some); } else if ctx.item.node.name.node == "edges" { let ctx_obj = ctx.with_selection_set(&ctx.item.node.selection_set); - return OutputValueType::resolve(&self.edges, &ctx_obj, ctx.item) + return OutputType::resolve(&self.edges, &ctx_obj, ctx.item) .await .map(Some); } @@ -222,10 +222,10 @@ where } #[async_trait::async_trait] -impl OutputValueType for Connection +impl OutputType for Connection where C: CursorType + Send + Sync, - T: OutputValueType + Send + Sync, + T: OutputType + Send + Sync, EC: ObjectType + Sync + Send, EE: ObjectType + Sync + Send, { @@ -241,7 +241,7 @@ where impl ObjectType for Connection where C: CursorType + Send + Sync, - T: OutputValueType + Send + Sync, + T: OutputType + Send + Sync, EC: ObjectType + Sync + Send, EE: ObjectType + Sync + Send, { diff --git a/src/types/connection/edge.rs b/src/types/connection/edge.rs index d35ddd18..bfc2eedc 100644 --- a/src/types/connection/edge.rs +++ b/src/types/connection/edge.rs @@ -7,8 +7,8 @@ use crate::parser::types::Field; use crate::resolver_utils::{resolve_container, ContainerType}; use crate::types::connection::CursorType; use crate::{ - registry, Context, ContextSelectionSet, ObjectType, OutputValueType, Positioned, ServerResult, - Type, Value, + registry, Context, ContextSelectionSet, ObjectType, OutputType, Positioned, ServerResult, Type, + Value, }; /// The edge type output by the data source @@ -43,7 +43,7 @@ impl Edge { impl Type for Edge where C: CursorType, - T: OutputValueType + Send + Sync, + T: OutputType + Send + Sync, E: ObjectType + Sync + Send, { fn type_name() -> Cow<'static, str> { @@ -111,13 +111,13 @@ where impl ContainerType for Edge where C: CursorType + Send + Sync, - T: OutputValueType + Send + Sync, + T: OutputType + Send + Sync, E: ObjectType + Sync + Send, { async fn resolve_field(&self, ctx: &Context<'_>) -> ServerResult> { if ctx.item.node.name.node == "node" { let ctx_obj = ctx.with_selection_set(&ctx.item.node.selection_set); - return OutputValueType::resolve(&self.node, &ctx_obj, ctx.item) + return OutputType::resolve(&self.node, &ctx_obj, ctx.item) .await .map(Some); } else if ctx.item.node.name.node == "cursor" { @@ -129,10 +129,10 @@ where } #[async_trait::async_trait] -impl OutputValueType for Edge +impl OutputType for Edge where C: CursorType + Send + Sync, - T: OutputValueType + Send + Sync, + T: OutputType + Send + Sync, E: ObjectType + Sync + Send, { async fn resolve( @@ -147,7 +147,7 @@ where impl ObjectType for Edge where C: CursorType + Send + Sync, - T: OutputValueType + Send + Sync, + T: OutputType + Send + Sync, E: ObjectType + Sync + Send, { } diff --git a/src/types/empty_mutation.rs b/src/types/empty_mutation.rs index daf4412e..016f0cf9 100644 --- a/src/types/empty_mutation.rs +++ b/src/types/empty_mutation.rs @@ -3,7 +3,7 @@ use std::borrow::Cow; use crate::parser::types::Field; use crate::resolver_utils::ContainerType; use crate::{ - registry, Context, ContextSelectionSet, ObjectType, OutputValueType, Positioned, ServerError, + registry, Context, ContextSelectionSet, ObjectType, OutputType, Positioned, ServerError, ServerResult, Type, Value, }; @@ -60,7 +60,7 @@ impl ContainerType for EmptyMutation { } #[async_trait::async_trait] -impl OutputValueType for EmptyMutation { +impl OutputType for EmptyMutation { async fn resolve( &self, _ctx: &ContextSelectionSet<'_>, diff --git a/src/types/external/cow.rs b/src/types/external/cow.rs index 71921e6a..e7ca6d61 100644 --- a/src/types/external/cow.rs +++ b/src/types/external/cow.rs @@ -1,8 +1,6 @@ use std::borrow::Cow; -use crate::{ - registry, ContextSelectionSet, OutputValueType, Positioned, ServerResult, Type, Value, -}; +use crate::{registry, ContextSelectionSet, OutputType, Positioned, ServerResult, Type, Value}; use async_graphql_parser::types::Field; impl<'a, T> Type for Cow<'a, T> @@ -19,9 +17,9 @@ where } #[async_trait::async_trait] -impl<'a, T> OutputValueType for Cow<'a, T> +impl<'a, T> OutputType for Cow<'a, T> where - T: OutputValueType + ToOwned + ?Sized + Send + Sync, + T: OutputType + ToOwned + ?Sized + Send + Sync, ::Owned: Send + Sync, { async fn resolve( diff --git a/src/types/external/json_object/btreemap.rs b/src/types/external/json_object/btreemap.rs index d7a7e4ef..2284d8c5 100644 --- a/src/types/external/json_object/btreemap.rs +++ b/src/types/external/json_object/btreemap.rs @@ -1,15 +1,14 @@ use std::collections::BTreeMap; use crate::{ - InputValueError, InputValueResult, InputValueType, Name, OutputValueType, Scalar, ScalarType, - Value, + InputType, InputValueError, InputValueResult, Name, OutputType, Scalar, ScalarType, Value, }; /// A scalar that can represent any JSON Object value. #[Scalar(internal, name = "JSONObject")] impl ScalarType for BTreeMap where - T: OutputValueType + InputValueType + Send + Sync, + T: OutputType + InputType + Send + Sync, { fn parse(value: Value) -> InputValueResult { match value { diff --git a/src/types/external/json_object/hashmap.rs b/src/types/external/json_object/hashmap.rs index 6ef1ab67..71218151 100644 --- a/src/types/external/json_object/hashmap.rs +++ b/src/types/external/json_object/hashmap.rs @@ -1,15 +1,14 @@ use std::collections::{BTreeMap, HashMap}; use crate::{ - InputValueError, InputValueResult, InputValueType, Name, OutputValueType, Scalar, ScalarType, - Value, + InputType, InputValueError, InputValueResult, Name, OutputType, Scalar, ScalarType, Value, }; /// A scalar that can represent any JSON Object value. #[Scalar(internal, name = "JSONObject")] impl ScalarType for HashMap where - T: OutputValueType + InputValueType + Send + Sync, + T: OutputType + InputType + Send + Sync, { fn parse(value: Value) -> InputValueResult { match value { diff --git a/src/types/external/list/btree_set.rs b/src/types/external/list/btree_set.rs index db24181f..5f3cad47 100644 --- a/src/types/external/list/btree_set.rs +++ b/src/types/external/list/btree_set.rs @@ -4,8 +4,8 @@ use std::collections::BTreeSet; use crate::parser::types::Field; use crate::resolver_utils::resolve_list; use crate::{ - registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType, - OutputValueType, Positioned, ServerResult, Type, Value, + registry, ContextSelectionSet, InputType, InputValueError, InputValueResult, OutputType, + Positioned, ServerResult, Type, Value, }; impl Type for BTreeSet { @@ -23,31 +23,29 @@ impl Type for BTreeSet { } } -impl InputValueType for BTreeSet { +impl InputType for BTreeSet { fn parse(value: Option) -> InputValueResult { match value.unwrap_or_default() { Value::List(values) => values .into_iter() - .map(|value| InputValueType::parse(Some(value))) + .map(|value| InputType::parse(Some(value))) .collect::>() .map_err(InputValueError::propagate), value => Ok({ let mut result = Self::default(); - result.insert( - InputValueType::parse(Some(value)).map_err(InputValueError::propagate)?, - ); + result.insert(InputType::parse(Some(value)).map_err(InputValueError::propagate)?); result }), } } fn to_value(&self) -> Value { - Value::List(self.iter().map(InputValueType::to_value).collect()) + Value::List(self.iter().map(InputType::to_value).collect()) } } #[async_trait::async_trait] -impl OutputValueType for BTreeSet { +impl OutputType for BTreeSet { async fn resolve( &self, ctx: &ContextSelectionSet<'_>, diff --git a/src/types/external/list/hash_set.rs b/src/types/external/list/hash_set.rs index 226b7bdc..b1fa24f9 100644 --- a/src/types/external/list/hash_set.rs +++ b/src/types/external/list/hash_set.rs @@ -6,8 +6,8 @@ use std::hash::Hash; use crate::parser::types::Field; use crate::resolver_utils::resolve_list; use crate::{ - registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType, - OutputValueType, Positioned, Result, ServerResult, Type, Value, + registry, ContextSelectionSet, InputType, InputValueError, InputValueResult, OutputType, + Positioned, Result, ServerResult, Type, Value, }; impl Type for HashSet { @@ -25,31 +25,29 @@ impl Type for HashSet { } } -impl InputValueType for HashSet { +impl InputType for HashSet { fn parse(value: Option) -> InputValueResult { match value.unwrap_or_default() { Value::List(values) => values .into_iter() - .map(|value| InputValueType::parse(Some(value))) + .map(|value| InputType::parse(Some(value))) .collect::>() .map_err(InputValueError::propagate), value => Ok({ let mut result = Self::default(); - result.insert( - InputValueType::parse(Some(value)).map_err(InputValueError::propagate)?, - ); + result.insert(InputType::parse(Some(value)).map_err(InputValueError::propagate)?); result }), } } fn to_value(&self) -> Value { - Value::List(self.iter().map(InputValueType::to_value).collect()) + Value::List(self.iter().map(InputType::to_value).collect()) } } #[async_trait::async_trait] -impl OutputValueType for HashSet { +impl OutputType for HashSet { async fn resolve( &self, ctx: &ContextSelectionSet<'_>, diff --git a/src/types/external/list/linked_list.rs b/src/types/external/list/linked_list.rs index 9a535d56..309d6854 100644 --- a/src/types/external/list/linked_list.rs +++ b/src/types/external/list/linked_list.rs @@ -4,8 +4,8 @@ use std::collections::LinkedList; use crate::parser::types::Field; use crate::resolver_utils::resolve_list; use crate::{ - registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType, - OutputValueType, Positioned, ServerResult, Type, Value, + registry, ContextSelectionSet, InputType, InputValueError, InputValueResult, OutputType, + Positioned, ServerResult, Type, Value, }; impl Type for LinkedList { @@ -23,31 +23,30 @@ impl Type for LinkedList { } } -impl InputValueType for LinkedList { +impl InputType for LinkedList { fn parse(value: Option) -> InputValueResult { match value.unwrap_or_default() { Value::List(values) => values .into_iter() - .map(|value| InputValueType::parse(Some(value))) + .map(|value| InputType::parse(Some(value))) .collect::>() .map_err(InputValueError::propagate), value => Ok({ let mut result = Self::default(); - result.push_front( - InputValueType::parse(Some(value)).map_err(InputValueError::propagate)?, - ); + result + .push_front(InputType::parse(Some(value)).map_err(InputValueError::propagate)?); result }), } } fn to_value(&self) -> Value { - Value::List(self.iter().map(InputValueType::to_value).collect()) + Value::List(self.iter().map(InputType::to_value).collect()) } } #[async_trait::async_trait] -impl OutputValueType for LinkedList { +impl OutputType for LinkedList { async fn resolve( &self, ctx: &ContextSelectionSet<'_>, diff --git a/src/types/external/list/slice.rs b/src/types/external/list/slice.rs index 57b10481..4ac83b3a 100644 --- a/src/types/external/list/slice.rs +++ b/src/types/external/list/slice.rs @@ -2,9 +2,7 @@ use std::borrow::Cow; use crate::parser::types::Field; use crate::resolver_utils::resolve_list; -use crate::{ - registry, ContextSelectionSet, OutputValueType, Positioned, ServerResult, Type, Value, -}; +use crate::{registry, ContextSelectionSet, OutputType, Positioned, ServerResult, Type, Value}; impl<'a, T: Type + 'a> Type for &'a [T] { fn type_name() -> Cow<'static, str> { @@ -22,7 +20,7 @@ impl<'a, T: Type + 'a> Type for &'a [T] { } #[async_trait::async_trait] -impl OutputValueType for &[T] { +impl OutputType for &[T] { async fn resolve( &self, ctx: &ContextSelectionSet<'_>, diff --git a/src/types/external/list/vec.rs b/src/types/external/list/vec.rs index eb53a24c..c9b9e357 100644 --- a/src/types/external/list/vec.rs +++ b/src/types/external/list/vec.rs @@ -3,8 +3,8 @@ use std::borrow::Cow; use crate::parser::types::Field; use crate::resolver_utils::resolve_list; use crate::{ - registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType, - OutputValueType, Positioned, Result, ServerResult, Type, Value, + registry, ContextSelectionSet, InputType, InputValueError, InputValueResult, OutputType, + Positioned, Result, ServerResult, Type, Value, }; impl Type for Vec { @@ -22,27 +22,27 @@ impl Type for Vec { } } -impl InputValueType for Vec { +impl InputType for Vec { fn parse(value: Option) -> InputValueResult { match value.unwrap_or_default() { Value::List(values) => values .into_iter() - .map(|value| InputValueType::parse(Some(value))) + .map(|value| InputType::parse(Some(value))) .collect::>() .map_err(InputValueError::propagate), value => Ok(vec![ - InputValueType::parse(Some(value)).map_err(InputValueError::propagate)? + InputType::parse(Some(value)).map_err(InputValueError::propagate)? ]), } } fn to_value(&self) -> Value { - Value::List(self.iter().map(InputValueType::to_value).collect()) + Value::List(self.iter().map(InputType::to_value).collect()) } } #[async_trait::async_trait] -impl OutputValueType for Vec { +impl OutputType for Vec { async fn resolve( &self, ctx: &ContextSelectionSet<'_>, diff --git a/src/types/external/list/vec_deque.rs b/src/types/external/list/vec_deque.rs index 82314d67..443ead24 100644 --- a/src/types/external/list/vec_deque.rs +++ b/src/types/external/list/vec_deque.rs @@ -4,8 +4,8 @@ use std::collections::VecDeque; use crate::parser::types::Field; use crate::resolver_utils::resolve_list; use crate::{ - registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType, - OutputValueType, Positioned, ServerResult, Type, Value, + registry, ContextSelectionSet, InputType, InputValueError, InputValueResult, OutputType, + Positioned, ServerResult, Type, Value, }; impl Type for VecDeque { @@ -23,31 +23,30 @@ impl Type for VecDeque { } } -impl InputValueType for VecDeque { +impl InputType for VecDeque { fn parse(value: Option) -> InputValueResult { match value.unwrap_or_default() { Value::List(values) => values .into_iter() - .map(|value| InputValueType::parse(Some(value))) + .map(|value| InputType::parse(Some(value))) .collect::>() .map_err(InputValueError::propagate), value => Ok({ let mut result = Self::default(); - result.push_back( - InputValueType::parse(Some(value)).map_err(InputValueError::propagate)?, - ); + result + .push_back(InputType::parse(Some(value)).map_err(InputValueError::propagate)?); result }), } } fn to_value(&self) -> Value { - Value::List(self.iter().map(InputValueType::to_value).collect()) + Value::List(self.iter().map(InputType::to_value).collect()) } } #[async_trait::async_trait] -impl OutputValueType for VecDeque { +impl OutputType for VecDeque { async fn resolve( &self, ctx: &ContextSelectionSet<'_>, diff --git a/src/types/external/optional.rs b/src/types/external/optional.rs index 4b027ae8..6d7fd1d6 100644 --- a/src/types/external/optional.rs +++ b/src/types/external/optional.rs @@ -2,8 +2,8 @@ use std::borrow::Cow; use crate::parser::types::Field; use crate::{ - registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType, - OutputValueType, Positioned, ServerResult, Type, Value, + registry, ContextSelectionSet, InputType, InputValueError, InputValueResult, OutputType, + Positioned, ServerResult, Type, Value, }; impl Type for Option { @@ -21,7 +21,7 @@ impl Type for Option { } } -impl InputValueType for Option { +impl InputType for Option { fn parse(value: Option) -> InputValueResult { match value.unwrap_or_default() { Value::Null => Ok(None), @@ -40,14 +40,14 @@ impl InputValueType for Option { } #[async_trait::async_trait] -impl OutputValueType for Option { +impl OutputType for Option { async fn resolve( &self, ctx: &ContextSelectionSet<'_>, field: &Positioned, ) -> ServerResult { if let Some(inner) = self { - OutputValueType::resolve(inner, ctx, field).await + OutputType::resolve(inner, ctx, field).await } else { Ok(Value::Null) } diff --git a/src/types/external/string.rs b/src/types/external/string.rs index cfd766f5..3852c51d 100644 --- a/src/types/external/string.rs +++ b/src/types/external/string.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use crate::parser::types::Field; use crate::{ - registry, ContextSelectionSet, InputValueError, InputValueResult, OutputValueType, Positioned, + registry, ContextSelectionSet, InputValueError, InputValueResult, OutputType, Positioned, Scalar, ScalarType, ServerResult, Type, Value, }; @@ -36,7 +36,7 @@ impl Type for str { } #[async_trait::async_trait] -impl OutputValueType for str { +impl OutputType for str { async fn resolve( &self, _: &ContextSelectionSet<'_>, diff --git a/src/types/json.rs b/src/types/json.rs index 57c3c0e9..fb116e7b 100644 --- a/src/types/json.rs +++ b/src/types/json.rs @@ -7,8 +7,8 @@ use serde::{Deserialize, Serialize}; use crate::parser::types::Field; use crate::registry::{MetaType, Registry}; use crate::{ - from_value, to_value, ContextSelectionSet, InputValueResult, OutputValueType, Positioned, - Scalar, ScalarType, ServerResult, Type, Value, + from_value, to_value, ContextSelectionSet, InputValueResult, OutputType, Positioned, Scalar, + ScalarType, ServerResult, Type, Value, }; /// A scalar that can represent any JSON value. @@ -50,7 +50,7 @@ impl ScalarType for Json { } } -/// A `Json` type that only implements `OutputValueType`. +/// A `Json` type that only implements `OutputType`. #[derive(Serialize, Clone, Debug, Eq, PartialEq, Hash, Default)] pub struct OutputJson(pub T); @@ -89,7 +89,7 @@ impl Type for OutputJson { } #[async_trait::async_trait] -impl OutputValueType for OutputJson { +impl OutputType for OutputJson { async fn resolve( &self, _ctx: &ContextSelectionSet<'_>, diff --git a/src/types/maybe_undefined.rs b/src/types/maybe_undefined.rs index 7d50454c..5e776ca1 100644 --- a/src/types/maybe_undefined.rs +++ b/src/types/maybe_undefined.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use crate::{registry, InputValueError, InputValueResult, InputValueType, Type, Value}; +use crate::{registry, InputType, InputValueError, InputValueResult, Type, Value}; /// Similar to `Option`, but it has three states, `undefined`, `null` and `x`. /// @@ -114,7 +114,7 @@ impl Type for MaybeUndefined { } } -impl InputValueType for MaybeUndefined { +impl InputType for MaybeUndefined { fn parse(value: Option) -> InputValueResult { match value { None => Ok(MaybeUndefined::Undefined), diff --git a/src/types/merged_object.rs b/src/types/merged_object.rs index dbe8b45f..394b4e87 100644 --- a/src/types/merged_object.rs +++ b/src/types/merged_object.rs @@ -6,8 +6,8 @@ use crate::parser::types::Field; use crate::registry::{MetaType, Registry}; use crate::resolver_utils::resolve_container; use crate::{ - CacheControl, ContainerType, Context, ContextSelectionSet, ObjectType, OutputValueType, - Positioned, ServerResult, SimpleObject, Type, Value, + CacheControl, ContainerType, Context, ContextSelectionSet, ObjectType, OutputType, Positioned, + ServerResult, SimpleObject, Type, Value, }; use async_graphql_value::ConstValue; @@ -84,7 +84,7 @@ where } #[async_trait::async_trait] -impl OutputValueType for MergedObject +impl OutputType for MergedObject where A: ObjectType + Send + Sync, B: ObjectType + Send + Sync, diff --git a/src/types/query_root.rs b/src/types/query_root.rs index 9d417f59..4096ab8f 100644 --- a/src/types/query_root.rs +++ b/src/types/query_root.rs @@ -6,8 +6,8 @@ use crate::model::{__Schema, __Type}; use crate::parser::types::Field; use crate::resolver_utils::{resolve_container, ContainerType}; use crate::{ - registry, Any, Context, ContextSelectionSet, ObjectType, OutputValueType, Positioned, - ServerError, ServerResult, SimpleObject, Type, Value, + registry, Any, Context, ContextSelectionSet, ObjectType, OutputType, Positioned, ServerError, + ServerResult, SimpleObject, Type, Value, }; /// Federation service @@ -89,7 +89,7 @@ impl ContainerType for QueryRoot { } let ctx_obj = ctx.with_selection_set(&ctx.item.node.selection_set); - return OutputValueType::resolve( + return OutputType::resolve( &__Schema { registry: &ctx.schema_env.registry, }, @@ -101,7 +101,7 @@ impl ContainerType for QueryRoot { } else if ctx.item.node.name.node == "__type" { let type_name: String = ctx.param_value("name", None)?; let ctx_obj = ctx.with_selection_set(&ctx.item.node.selection_set); - return OutputValueType::resolve( + return OutputType::resolve( &ctx.schema_env .registry .types @@ -126,7 +126,7 @@ impl ContainerType for QueryRoot { return Ok(Some(Value::List(res))); } else if ctx.item.node.name.node == "_service" { let ctx_obj = ctx.with_selection_set(&ctx.item.node.selection_set); - return OutputValueType::resolve( + return OutputType::resolve( &Service { sdl: Some(ctx.schema_env.registry.export_sdl(true)), }, @@ -142,7 +142,7 @@ impl ContainerType for QueryRoot { } #[async_trait::async_trait] -impl OutputValueType for QueryRoot { +impl OutputType for QueryRoot { async fn resolve( &self, ctx: &ContextSelectionSet<'_>, diff --git a/src/types/upload.rs b/src/types/upload.rs index 4d1da8fb..25fccaaf 100644 --- a/src/types/upload.rs +++ b/src/types/upload.rs @@ -5,7 +5,7 @@ use std::io::Read; #[cfg(feature = "unblock")] use futures_util::io::AsyncRead; -use crate::{registry, Context, InputValueError, InputValueResult, InputValueType, Type, Value}; +use crate::{registry, Context, InputType, InputValueError, InputValueResult, Type, Value}; /// A file upload value. pub struct UploadValue { @@ -114,7 +114,7 @@ impl Type for Upload { } } -impl InputValueType for Upload { +impl InputType for Upload { fn parse(value: Option) -> InputValueResult { const PREFIX: &str = "#__graphql_file__:"; let value = value.unwrap_or_default();