Skip to content

Commit 778606c

Browse files
committed
Fix bad merge [skip ci]
1 parent e344f1c commit 778606c

File tree

14 files changed

+55
-74
lines changed

14 files changed

+55
-74
lines changed

examples/warp_async/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ reqwest = "0.9.19"
1616
juniper_codegen = { git = "https://github.com/graphql-rust/juniper", branch = "async-await", features = ["async"] }
1717
juniper = { git = "https://github.com/graphql-rust/juniper", branch = "async-await", features = ["async"] }
1818
juniper_warp = { git = "https://github.com/graphql-rust/juniper", branch = "async-await", features = ["async"] }
19+

examples/warp_async/src/main.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
//! This example demonstrates async/await usage with warp.
33
//! NOTE: this uses tokio 0.1 , not the alpha tokio 0.2.
44
5-
use juniper::{EmptyMutation, FieldError, RootNode};
5+
use juniper::{EmptyMutation, RootNode, FieldError};
66
use warp::{http::Response, Filter};
77

88
#[derive(Clone)]
9-
struct Context {}
9+
struct Context {
10+
11+
}
1012
impl juniper::Context for Context {}
1113

1214
#[derive(juniper::GraphQLEnum, Clone, Copy)]
@@ -46,19 +48,18 @@ struct Query;
4648
#[juniper::object(Context = Context)]
4749
impl Query {
4850
async fn users() -> Vec<User> {
49-
vec![User {
50-
id: 1,
51-
kind: UserKind::Admin,
52-
name: "user1".into(),
53-
}]
51+
vec![
52+
User{
53+
id: 1,
54+
kind: UserKind::Admin,
55+
name: "user1".into(),
56+
},
57+
]
5458
}
5559

5660
/// Fetch a URL and return the response body text.
5761
async fn request(url: String) -> Result<String, FieldError> {
58-
use futures::{
59-
compat::{Future01CompatExt, Stream01CompatExt},
60-
stream::TryStreamExt,
61-
};
62+
use futures::{ compat::{Stream01CompatExt, Future01CompatExt}, stream::TryStreamExt};
6263

6364
let res = reqwest::r#async::Client::new()
6465
.get(&url)
@@ -94,7 +95,7 @@ fn main() {
9495

9596
log::info!("Listening on 127.0.0.1:8080");
9697

97-
let state = warp::any().map(move || Context {});
98+
let state = warp::any().map(move || Context{} );
9899
let graphql_filter = juniper_warp::make_graphql_filter_async(schema(), state.boxed());
99100

100101
warp::serve(
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11

2+
3+
4+

juniper/src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ mod executor_tests;
151151
pub use crate::util::to_camel_case;
152152

153153
use crate::{
154-
executor::{execute_validated_query, execute_validated_query_async},
155154
introspection::{INTROSPECTION_QUERY, INTROSPECTION_QUERY_WITHOUT_DESCRIPTIONS},
156155
parser::{parse_document_source, ParseError, Spanning},
157156
validation::{validate_input_values, visit_all_rules, ValidatorContext},
@@ -228,7 +227,7 @@ where
228227
}
229228
}
230229

231-
execute_validated_query(document, operation_name, root_node, variables, context)
230+
executor::execute_validated_query(document, operation_name, root_node, variables, context)
232231
}
233232

234233
/// Execute a query in a provided schema
@@ -268,7 +267,7 @@ where
268267
}
269268
}
270269

271-
execute_validated_query_async(document, operation_name, root_node, variables, context)
270+
executor::execute_validated_query_async(document, operation_name, root_node, variables, context)
272271
.await
273272
}
274273

juniper/src/macros/common.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ macro_rules! __juniper_impl_trait {
77
}
88
) => {
99
impl<$($other,)*> $crate::$impl_trait<$crate::DefaultScalarValue> for $name {
10-
$($body)+
10+
$($body)*
1111
}
1212
};
1313
(
@@ -26,7 +26,7 @@ macro_rules! __juniper_impl_trait {
2626

2727
(
2828
impl< <$generic:tt $(: $bound: tt)*> $(, $other: tt)* > $impl_trait:tt for $name:ty {
29-
$($body:tt)+
29+
$($body:tt)*
3030
}
3131
) => {
3232
impl<$($other,)* $generic $(: $bound)*> $crate::$impl_trait<$generic> for $name
@@ -50,17 +50,17 @@ macro_rules! __juniper_impl_trait {
5050
$generic: $crate::ScalarValue,
5151
for<'__b> &'__b $generic: $crate::ScalarRefValue<'__b>,
5252
{
53-
$($body)+
53+
$($body)*
5454
}
5555
};
5656

5757
(
5858
impl<$scalar:ty $(, $other: tt )*> $impl_trait:tt for $name:ty {
59-
$($body:tt)+
59+
$($body:tt)*
6060
}
6161
) => {
6262
impl<$($other, )*> $crate::$impl_trait<$scalar> for $name {
63-
$($body)+
63+
$($body)*
6464
}
6565
};
6666
(

juniper/src/macros/tests/field.rs

-3
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,13 @@ impl Root {
9595
Ok(0)
9696
}
9797

98-
/*
99-
* FIXME: make this work again
10098
fn with_return() -> i32 {
10199
return 0;
102100
}
103101

104102
fn with_return_field_result() -> FieldResult<i32> {
105103
return Ok(0);
106104
}
107-
*/
108105
}
109106

110107
graphql_interface!(Interface: () |&self| {

juniper/src/macros/tests/union.rs

-19
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
use std::marker::PhantomData;
2-
3-
use crate::{
4-
ast::InputValue,
5-
schema::model::RootNode,
6-
types::scalars::EmptyMutation,
7-
value::{DefaultScalarValue, Object, Value},
8-
};
9-
101
/*
112
123
Syntax to validate:
@@ -44,16 +35,6 @@ enum WithGenerics<T> {
4435
enum DescriptionFirst {
4536
Concrete(Concrete),
4637
}
47-
enum ResolversFirst {
48-
Concrete(Concrete),
49-
}
50-
51-
enum CommasWithTrailing {
52-
Concrete(Concrete),
53-
}
54-
enum ResolversWithTrailingComma {
55-
Concrete(Concrete),
56-
}
5738

5839
struct Root;
5940

juniper/src/schema/schema.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,13 @@ where
9898
) -> ExecutionResult<S> {
9999
use futures::future::{ready, FutureExt};
100100
match field_name {
101-
"__schema" | "__type" => self.resolve_field(info, field_name, arguments, executor),
102-
_ => {
103-
self.query_type
104-
.resolve_field_async(info, field_name, arguments, executor)
105-
.await
101+
"__schema" | "__type" => {
102+
let v = self.resolve_field(info, field_name, arguments, executor);
103+
Box::pin(ready(v))
106104
}
105+
_ => self
106+
.query_type
107+
.resolve_field_async(info, field_name, arguments, executor),
107108
}
108109
}
109110
}

juniper/src/tests/introspection_tests.rs

-3
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ fn test_introspection_possible_types() {
234234
assert_eq!(possible_types, vec!["Human", "Droid"].into_iter().collect());
235235
}
236236

237-
/*
238-
* FIXME: make this work again
239237
#[test]
240238
fn test_builtin_introspection_query() {
241239
let database = Database::new();
@@ -258,4 +256,3 @@ fn test_builtin_introspection_query_without_descriptions() {
258256

259257
assert_eq!(result, (expected, vec![]));
260258
}
261-
*/

juniper/src/types/async_await.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
use crate::{
22
ast::{Directive, FromInputValue, InputValue, Selection},
3+
value::{Object, ScalarRefValue, ScalarValue, Value},
4+
};
5+
6+
use crate::{
37
executor::{ExecutionResult, Executor},
48
parser::Spanning,
5-
value::{Object, ScalarRefValue, ScalarValue, Value},
6-
BoxFuture,
79
};
810

11+
use crate::BoxFuture;
12+
913
use super::base::{is_excluded, merge_key_into, Arguments, GraphQLType};
1014

1115
#[async_trait::async_trait]

juniper_codegen/src/impl_object.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,17 @@ pub fn build_object(args: TokenStream, body: TokenStream, is_internal: bool) ->
4141
}
4242
}
4343

44-
let name = if let Some(name) = impl_attrs.name.as_ref() {
44+
45+
let name = if let Some(name) = impl_attrs.name.as_ref(){
4546
name.to_string()
46-
} else {
47+
}
48+
else {
4749
if let Some(ident) = util::name_of_type(&*_impl.self_ty) {
4850
ident.to_string()
4951
} else {
50-
panic!("Could not determine a name for the object type: specify one with #[juniper::object(name = \"SomeName\")");
51-
}
52-
};
52+
panic!("Could not determine a name for the object type: specify one with #[juniper::object(name = \"SomeName\")");
53+
}
54+
};
5355

5456
let target_type = *_impl.self_ty.clone();
5557

juniper_codegen/src/impl_union.rs

+9-16
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub fn impl_union(
6767
attrs: TokenStream,
6868
body: TokenStream,
6969
) -> Result<TokenStream, MacroError> {
70+
7071
// We are re-using the object attributes since they are almost the same.
7172
let attrs = syn::parse::<util::ObjectAttributes>(attrs)?;
7273

@@ -75,8 +76,7 @@ pub fn impl_union(
7576
if item.items.len() != 1 {
7677
return Err(MacroError::new(
7778
item.span(),
78-
"Invalid impl body: expected one method with signature: fn resolve(&self) { ... }"
79-
.to_string(),
79+
"Invalid impl body: expected one method with signature: fn resolve(&self) { ... }".to_string(),
8080
));
8181
}
8282

@@ -92,7 +92,7 @@ pub fn impl_union(
9292
"Expected a path ending in a simple type identifier".to_string(),
9393
)
9494
})?;
95-
let name = attrs.name.unwrap_or_else(|| ty_ident.to_string());
95+
let name = attrs.name.unwrap_or_else(|| ty_ident.to_string());
9696

9797
let juniper = util::juniper_path(is_internal);
9898

@@ -130,9 +130,7 @@ pub fn impl_union(
130130
.scalar
131131
.as_ref()
132132
.map(|s| quote!( #s ))
133-
.unwrap_or_else(|| {
134-
quote! { #juniper::DefaultScalarValue }
135-
});
133+
.unwrap_or_else(|| { quote! { #juniper::DefaultScalarValue } });
136134

137135
let mut generics = item.generics.clone();
138136
if attrs.scalar.is_some() {
@@ -141,12 +139,10 @@ pub fn impl_union(
141139
// compatible with ScalarValueRef.
142140
// This is done to prevent the user from having to specify this
143141
// manually.
144-
let where_clause = generics
145-
.where_clause
146-
.get_or_insert(syn::parse_quote!(where));
147-
where_clause
148-
.predicates
149-
.push(syn::parse_quote!(for<'__b> &'__b #scalar: #juniper::ScalarRefValue<'__b>));
142+
let where_clause = generics.where_clause.get_or_insert(syn::parse_quote!(where));
143+
where_clause.predicates.push(
144+
syn::parse_quote!(for<'__b> &'__b #scalar: #juniper::ScalarRefValue<'__b>),
145+
);
150146
}
151147

152148
let (impl_generics, _, where_clause) = generics.split_for_impl();
@@ -155,10 +151,7 @@ pub fn impl_union(
155151
Some(value) => quote!( .description( #value ) ),
156152
None => quote!(),
157153
};
158-
let context = attrs
159-
.context
160-
.map(|c| quote! { #c })
161-
.unwrap_or_else(|| quote! { () });
154+
let context = attrs.context.map(|c| quote!{ #c } ).unwrap_or_else(|| quote!{ () });
162155

163156
let output = quote! {
164157
impl #impl_generics #juniper::GraphQLType<#scalar> for #ty #where_clause

juniper_codegen/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -389,3 +389,4 @@ pub fn union_internal(attrs: TokenStream, body: TokenStream) -> TokenStream {
389389
};
390390
output
391391
}
392+

juniper_warp/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ Check the LICENSE file for details.
4141
#![doc(html_root_url = "https://docs.rs/juniper_warp/0.2.0")]
4242

4343
use futures::{future::poll_fn, Future};
44-
use juniper::{DefaultScalarValue, InputValue, ScalarRefValue, ScalarValue};
4544
use serde::Deserialize;
4645
use std::sync::Arc;
4746
use warp::{filters::BoxedFilter, Filter};
4847

4948
#[cfg(feature = "async")]
5049
use futures03::future::{FutureExt, TryFutureExt};
5150

51+
use juniper::{DefaultScalarValue, InputValue, ScalarRefValue, ScalarValue};
52+
5253
#[derive(Debug, serde_derive::Deserialize, PartialEq)]
5354
#[serde(untagged)]
5455
#[serde(bound = "InputValue<S>: Deserialize<'de>")]

0 commit comments

Comments
 (0)