From 5d270b7dea38f51246f5aa521e246b8a72cfdb97 Mon Sep 17 00:00:00 2001 From: Christoph Herzog <chris@theduke.at> Date: Fri, 15 Nov 2019 21:53:15 +0100 Subject: [PATCH] Formatting --- .../juniper_tests/src/codegen/derive_enum.rs | 5 ++++- .../src/codegen/derive_input_object.rs | 5 ++++- .../juniper_tests/src/codegen/derive_object.rs | 5 ++++- .../src/codegen/scalar_value_transparent.rs | 10 ++++++++-- .../juniper_tests/src/codegen/unions.rs | 3 --- juniper/src/types/async_await.rs | 4 ++-- juniper/src/types/base.rs | 11 ++++++----- juniper/src/types/containers.rs | 8 ++++---- juniper/src/types/pointers.rs | 2 +- juniper/src/types/scalars.rs | 2 +- juniper_codegen/src/impl_object.rs | 12 +++++------- juniper_codegen/src/impl_union.rs | 15 ++++++++++----- juniper_codegen/src/lib.rs | 1 - juniper_iron/src/lib.rs | 3 +-- juniper_rocket/src/lib.rs | 5 +---- 15 files changed, 51 insertions(+), 40 deletions(-) diff --git a/integration_tests/juniper_tests/src/codegen/derive_enum.rs b/integration_tests/juniper_tests/src/codegen/derive_enum.rs index 85d893f2..5dc1848e 100644 --- a/integration_tests/juniper_tests/src/codegen/derive_enum.rs +++ b/integration_tests/juniper_tests/src/codegen/derive_enum.rs @@ -42,7 +42,10 @@ enum OverrideDocEnum { #[test] fn test_derived_enum() { // Ensure that rename works. - assert_eq!(<SomeEnum as GraphQLType<DefaultScalarValue>>::name(&()), Some("Some")); + assert_eq!( + <SomeEnum as GraphQLType<DefaultScalarValue>>::name(&()), + Some("Some") + ); // Ensure validity of meta info. let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default()); diff --git a/integration_tests/juniper_tests/src/codegen/derive_input_object.rs b/integration_tests/juniper_tests/src/codegen/derive_input_object.rs index 17a425c4..5f4a5982 100644 --- a/integration_tests/juniper_tests/src/codegen/derive_input_object.rs +++ b/integration_tests/juniper_tests/src/codegen/derive_input_object.rs @@ -93,7 +93,10 @@ struct WithLifetime<'a> { #[test] fn test_derived_input_object() { - assert_eq!(<Input as GraphQLType<DefaultScalarValue>>::name(&()), Some("MyInput")); + assert_eq!( + <Input as GraphQLType<DefaultScalarValue>>::name(&()), + Some("MyInput") + ); // Validate meta info. let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default()); diff --git a/integration_tests/juniper_tests/src/codegen/derive_object.rs b/integration_tests/juniper_tests/src/codegen/derive_object.rs index a9cc839c..d53d8fa3 100644 --- a/integration_tests/juniper_tests/src/codegen/derive_object.rs +++ b/integration_tests/juniper_tests/src/codegen/derive_object.rs @@ -170,7 +170,10 @@ fn test_doc_comment_override() { #[test] fn test_derived_object() { - assert_eq!(<Obj as GraphQLType<DefaultScalarValue>>::name(&()), Some("MyObj")); + assert_eq!( + <Obj as GraphQLType<DefaultScalarValue>>::name(&()), + Some("MyObj") + ); // Verify meta info. let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default()); diff --git a/integration_tests/juniper_tests/src/codegen/scalar_value_transparent.rs b/integration_tests/juniper_tests/src/codegen/scalar_value_transparent.rs index ecb2299d..e65ea8bd 100644 --- a/integration_tests/juniper_tests/src/codegen/scalar_value_transparent.rs +++ b/integration_tests/juniper_tests/src/codegen/scalar_value_transparent.rs @@ -31,7 +31,10 @@ impl User2 { #[test] fn test_scalar_value_simple() { - assert_eq!(<UserId as GraphQLType<DefaultScalarValue>>::name(&()), Some("UserId")); + assert_eq!( + <UserId as GraphQLType<DefaultScalarValue>>::name(&()), + Some("UserId") + ); let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default()); let meta = UserId::meta(&(), &mut registry); @@ -49,7 +52,10 @@ fn test_scalar_value_simple() { #[test] fn test_scalar_value_custom() { - assert_eq!(<CustomUserId as GraphQLType<DefaultScalarValue>>::name(&()), Some("MyUserId")); + assert_eq!( + <CustomUserId as GraphQLType<DefaultScalarValue>>::name(&()), + Some("MyUserId") + ); let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default()); let meta = CustomUserId::meta(&(), &mut registry); diff --git a/integration_tests/juniper_tests/src/codegen/unions.rs b/integration_tests/juniper_tests/src/codegen/unions.rs index fd40910d..8b137891 100644 --- a/integration_tests/juniper_tests/src/codegen/unions.rs +++ b/integration_tests/juniper_tests/src/codegen/unions.rs @@ -1,4 +1 @@ - - - diff --git a/juniper/src/types/async_await.rs b/juniper/src/types/async_await.rs index 779cca56..53db423c 100644 --- a/juniper/src/types/async_await.rs +++ b/juniper/src/types/async_await.rs @@ -36,8 +36,8 @@ where ) -> BoxFuture<'a, ExecutionResult<S>> { if let Some(selection_set) = selection_set { Box::pin(async move { - let value = - resolve_selection_set_into_async(self, info, selection_set, executor).await; + let value = + resolve_selection_set_into_async(self, info, selection_set, executor).await; Ok(value) }) } else { diff --git a/juniper/src/types/base.rs b/juniper/src/types/base.rs index 4a95a855..bc4d0003 100644 --- a/juniper/src/types/base.rs +++ b/juniper/src/types/base.rs @@ -332,11 +332,12 @@ where ) -> ExecutionResult<S> { if let Some(selection_set) = selection_set { let mut result = Object::with_capacity(selection_set.len()); - let out = if resolve_selection_set_into(self, info, selection_set, executor, &mut result) { - Value::Object(result) - } else { - Value::null() - }; + let out = + if resolve_selection_set_into(self, info, selection_set, executor, &mut result) { + Value::Object(result) + } else { + Value::null() + }; Ok(out) } else { panic!("resolve() must be implemented by non-object output types"); diff --git a/juniper/src/types/containers.rs b/juniper/src/types/containers.rs index a3972b84..37b24e93 100644 --- a/juniper/src/types/containers.rs +++ b/juniper/src/types/containers.rs @@ -1,8 +1,8 @@ use crate::{ ast::{FromInputValue, InputValue, Selection, ToInputValue}, + executor::ExecutionResult, schema::meta::MetaType, value::{ScalarValue, Value}, - executor::ExecutionResult, }; use crate::{ @@ -196,9 +196,9 @@ where for o in iter { match executor.resolve(info, &o) { - Ok(value) if stop_on_null && value.is_null() => { return Ok(value) }, - Ok(value) => { result.push(value) }, - Err(e) => { return Err(e) }, + Ok(value) if stop_on_null && value.is_null() => return Ok(value), + Ok(value) => result.push(value), + Err(e) => return Err(e), } } diff --git a/juniper/src/types/pointers.rs b/juniper/src/types/pointers.rs index 3d3534fb..13cc17b3 100644 --- a/juniper/src/types/pointers.rs +++ b/juniper/src/types/pointers.rs @@ -5,7 +5,7 @@ use crate::{ executor::{ExecutionResult, Executor, Registry}, schema::meta::MetaType, types::base::{Arguments, GraphQLType}, - value::{ScalarValue}, + value::ScalarValue, }; impl<S, T, CtxT> GraphQLType<S> for Box<T> diff --git a/juniper/src/types/scalars.rs b/juniper/src/types/scalars.rs index 005f759a..8cdbea82 100644 --- a/juniper/src/types/scalars.rs +++ b/juniper/src/types/scalars.rs @@ -3,7 +3,7 @@ use std::{char, convert::From, marker::PhantomData, ops::Deref, u32}; use crate::{ ast::{InputValue, Selection, ToInputValue}, - executor::{Executor, Registry, ExecutionResult}, + executor::{ExecutionResult, Executor, Registry}, parser::{LexerError, ParseError, ScalarToken, Token}, schema::meta::MetaType, types::base::GraphQLType, diff --git a/juniper_codegen/src/impl_object.rs b/juniper_codegen/src/impl_object.rs index 308938cb..3613d36b 100644 --- a/juniper_codegen/src/impl_object.rs +++ b/juniper_codegen/src/impl_object.rs @@ -41,17 +41,15 @@ pub fn build_object(args: TokenStream, body: TokenStream, is_internal: bool) -> } } - - let name = if let Some(name) = impl_attrs.name.as_ref(){ + let name = if let Some(name) = impl_attrs.name.as_ref() { name.to_string() - } - else { + } else { if let Some(ident) = util::name_of_type(&*_impl.self_ty) { ident.to_string() } else { - panic!("Could not determine a name for the object type: specify one with #[juniper::object(name = \"SomeName\")"); - } - }; + panic!("Could not determine a name for the object type: specify one with #[juniper::object(name = \"SomeName\")"); + } + }; let target_type = *_impl.self_ty.clone(); diff --git a/juniper_codegen/src/impl_union.rs b/juniper_codegen/src/impl_union.rs index b83826b1..a448e345 100644 --- a/juniper_codegen/src/impl_union.rs +++ b/juniper_codegen/src/impl_union.rs @@ -67,7 +67,6 @@ pub fn impl_union( attrs: TokenStream, body: TokenStream, ) -> Result<TokenStream, MacroError> { - // We are re-using the object attributes since they are almost the same. let attrs = syn::parse::<util::ObjectAttributes>(attrs)?; @@ -76,7 +75,8 @@ pub fn impl_union( if item.items.len() != 1 { return Err(MacroError::new( item.span(), - "Invalid impl body: expected one method with signature: fn resolve(&self) { ... }".to_string(), + "Invalid impl body: expected one method with signature: fn resolve(&self) { ... }" + .to_string(), )); } @@ -92,7 +92,7 @@ pub fn impl_union( "Expected a path ending in a simple type identifier".to_string(), ) })?; - let name = attrs.name.unwrap_or_else(|| ty_ident.to_string()); + let name = attrs.name.unwrap_or_else(|| ty_ident.to_string()); let juniper = util::juniper_path(is_internal); @@ -130,7 +130,9 @@ pub fn impl_union( .scalar .as_ref() .map(|s| quote!( #s )) - .unwrap_or_else(|| { quote! { #juniper::DefaultScalarValue } }); + .unwrap_or_else(|| { + quote! { #juniper::DefaultScalarValue } + }); let generics = item.generics.clone(); let (impl_generics, _, where_clause) = generics.split_for_impl(); @@ -139,7 +141,10 @@ pub fn impl_union( Some(value) => quote!( .description( #value ) ), None => quote!(), }; - let context = attrs.context.map(|c| quote!{ #c } ).unwrap_or_else(|| quote!{ () }); + let context = attrs + .context + .map(|c| quote! { #c }) + .unwrap_or_else(|| quote! { () }); let output = quote! { impl #impl_generics #juniper::GraphQLType<#scalar> for #ty #where_clause diff --git a/juniper_codegen/src/lib.rs b/juniper_codegen/src/lib.rs index cd3a9903..8be08a51 100644 --- a/juniper_codegen/src/lib.rs +++ b/juniper_codegen/src/lib.rs @@ -407,4 +407,3 @@ pub fn union_internal(attrs: TokenStream, body: TokenStream) -> TokenStream { }; output } - diff --git a/juniper_iron/src/lib.rs b/juniper_iron/src/lib.rs index 591ea985..39271106 100644 --- a/juniper_iron/src/lib.rs +++ b/juniper_iron/src/lib.rs @@ -118,8 +118,7 @@ use std::{error::Error, fmt, io::Read}; use serde_json::error::Error as SerdeError; use juniper::{ - http, serde::Deserialize, DefaultScalarValue, GraphQLType, InputValue, RootNode, - ScalarValue, + http, serde::Deserialize, DefaultScalarValue, GraphQLType, InputValue, RootNode, ScalarValue, }; #[derive(serde_derive::Deserialize)] diff --git a/juniper_rocket/src/lib.rs b/juniper_rocket/src/lib.rs index a016f132..32f60209 100644 --- a/juniper_rocket/src/lib.rs +++ b/juniper_rocket/src/lib.rs @@ -57,8 +57,7 @@ use rocket::{ use juniper::{http, InputValue}; use juniper::{ - serde::Deserialize, DefaultScalarValue, FieldError, GraphQLType, RootNode, ScalarRefValue, - ScalarValue, + serde::Deserialize, DefaultScalarValue, FieldError, GraphQLType, RootNode, ScalarValue, }; #[derive(Debug, serde_derive::Deserialize, PartialEq)] @@ -85,7 +84,6 @@ where impl<S> GraphQLBatchRequest<S> where S: ScalarValue, - for<'b> &'b S: ScalarRefValue<'b>, { pub fn execute<'a, CtxT, QueryT, MutationT>( &'a self, @@ -161,7 +159,6 @@ pub fn playground_source(graphql_endpoint_url: &str) -> content::Html<String> { impl<S> GraphQLRequest<S> where S: ScalarValue, - for<'b> &'b S: ScalarRefValue<'b>, { /// Execute an incoming GraphQL query pub fn execute<CtxT, QueryT, MutationT>(