Skip to content

Resolve some todos in async-await branch #452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 53 commits into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
dd424f3
Bubble up scalar error (#434)
andy128k Oct 24, 2019
9be274a
Update CHANGELOG.md
LegNeato Oct 24, 2019
8628ddd
Make EmptyMutation `Send`
LegNeato Oct 24, 2019
6b7977b
Update CHANGELOG.md
LegNeato Oct 24, 2019
252f7b4
Release juniper_codegen 0.14.1
LegNeato Oct 24, 2019
c434bdd
Release juniper 0.14.1
LegNeato Oct 24, 2019
012c0b1
Release juniper_hyper 0.5.1
LegNeato Oct 24, 2019
0421f9a
Release juniper_iron 0.6.1
LegNeato Oct 24, 2019
7c98eaf
Release juniper_rocket 0.5.1
LegNeato Oct 24, 2019
91a9752
Release juniper_warp 0.5.1
LegNeato Oct 24, 2019
bd3d289
Resolve RFC 2565 related todos
nWacky Nov 1, 2019
0f4e998
Remove __juniper_extract_generic macro
nWacky Nov 1, 2019
13bbbe2
Start adding `async-trait` to `GraphQLTypeAsync`
nWacky Nov 1, 2019
563e44c
Merge remote-tracking branch 'upstream/async-await' into async-await
nWacky Nov 1, 2019
737c4c7
Add `resolve_into_type_async`
nWacky Nov 1, 2019
9e2a63a
Refactor `GraphQLTypeAsync` to use `async-trait`
nWacky Nov 1, 2019
9478b6c
Remove useless todo
nWacky Nov 4, 2019
91dc55b
Resolve better error message with field/type name todo, update other …
nWacky Nov 4, 2019
afd92cd
Format
nWacky Nov 4, 2019
2404b81
Rebase onto master
nWacky Nov 4, 2019
09d1077
Merge branch 'async-await-resolve-some-todos' of https://github.com/i…
nWacky Nov 4, 2019
503bb63
Format
nWacky Nov 4, 2019
e2ebaee
Merge import in `async_await`
nWacky Nov 4, 2019
3e5e2ae
Format
nWacky Nov 4, 2019
779208e
Bubble up scalar error (#434)
andy128k Oct 24, 2019
7230efc
Update CHANGELOG.md
LegNeato Oct 24, 2019
665c3d2
Make EmptyMutation `Send`
LegNeato Oct 24, 2019
bb99076
Update CHANGELOG.md
LegNeato Oct 24, 2019
7b18bd2
Release juniper_codegen 0.14.1
LegNeato Oct 24, 2019
191468b
Release juniper 0.14.1
LegNeato Oct 24, 2019
fed6950
Release juniper_hyper 0.5.1
LegNeato Oct 24, 2019
bf88826
Release juniper_iron 0.6.1
LegNeato Oct 24, 2019
c298697
Release juniper_rocket 0.5.1
LegNeato Oct 24, 2019
c24687d
Release juniper_warp 0.5.1
LegNeato Oct 24, 2019
d22b5c6
Resolve RFC 2565 related todos
nWacky Nov 1, 2019
bfe6c7a
Remove __juniper_extract_generic macro
nWacky Nov 1, 2019
e03e525
Start adding `async-trait` to `GraphQLTypeAsync`
nWacky Nov 1, 2019
820f472
Add `resolve_into_type_async`
nWacky Nov 1, 2019
52c3e28
Refactor `GraphQLTypeAsync` to use `async-trait`
nWacky Nov 1, 2019
b1970ae
Remove useless todo
nWacky Nov 4, 2019
00dd1dc
Resolve better error message with field/type name todo, update other …
nWacky Nov 4, 2019
e3c12e3
Format
nWacky Nov 4, 2019
dbcaf30
Rebase onto master
nWacky Nov 4, 2019
554ba34
Format
nWacky Nov 4, 2019
9506272
Merge import in `async_await`
nWacky Nov 4, 2019
7135c07
Format
nWacky Nov 4, 2019
ec76bf5
Fix cargo.toml in `warp_async`
nWacky Nov 5, 2019
99c0d26
Comment out `attr_arg_descr` and `attr_arg_descr_collapse` tests
nWacky Nov 5, 2019
e151026
Merge branch 'async-await-resolve-some-todos' of https://github.com/i…
nWacky Nov 5, 2019
4834349
Rebase onto `async-await`
nWacky Nov 6, 2019
09d9513
Rebase onto `master`
nWacky Nov 6, 2019
e344f1c
Merge branch 'async-await-resolve-some-todos' of https://github.com/i…
nWacky Nov 6, 2019
778606c
Fix bad merge [skip ci]
nWacky Nov 6, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/warp_async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ reqwest = "0.9.19"
juniper_codegen = { git = "https://github.com/graphql-rust/juniper", branch = "async-await", features = ["async"] }
juniper = { git = "https://github.com/graphql-rust/juniper", branch = "async-await", features = ["async"] }
juniper_warp = { git = "https://github.com/graphql-rust/juniper", branch = "async-await", features = ["async"] }

27 changes: 13 additions & 14 deletions examples/warp_async/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
//! This example demonstrates async/await usage with warp.
//! NOTE: this uses tokio 0.1 , not the alpha tokio 0.2.

use juniper::{EmptyMutation, RootNode, FieldError};
use juniper::{EmptyMutation, FieldError, RootNode};
use warp::{http::Response, Filter};

#[derive(Clone)]
struct Context {

}
struct Context {}
impl juniper::Context for Context {}

#[derive(juniper::GraphQLEnum, Clone, Copy)]
Expand Down Expand Up @@ -43,23 +41,24 @@ impl User {
}
}

struct Query;
struct Query;

#[juniper::object(Context = Context)]
impl Query {
async fn users() -> Vec<User> {
vec![
User{
id: 1,
kind: UserKind::Admin,
name: "user1".into(),
},
]
vec![User {
id: 1,
kind: UserKind::Admin,
name: "user1".into(),
}]
}

/// Fetch a URL and return the response body text.
async fn request(url: String) -> Result<String, FieldError> {
use futures::{ compat::{Stream01CompatExt, Future01CompatExt}, stream::TryStreamExt};
use futures::{
compat::{Future01CompatExt, Stream01CompatExt},
stream::TryStreamExt,
};

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

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

let state = warp::any().map(move || Context{} );
let state = warp::any().map(move || Context {});
let graphql_filter = juniper_warp::make_graphql_filter_async(schema(), state.boxed());

warp::serve(
Expand Down
3 changes: 0 additions & 3 deletions integration_tests/juniper_tests/src/codegen/unions.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@




5 changes: 5 additions & 0 deletions juniper/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

- No changes yet

# [[0.14.1] 2019-10-24](https://github.com/graphql-rust/juniper/releases/tag/juniper-0.14.1)

- Fix panic when an invalid scalar is used by a client [#434](https://github.com/graphql-rust/juniper/pull/434)
- `EmptyMutation` now implements `Send` [#443](https://github.com/graphql-rust/juniper/pull/443)

# [[0.14.0] 2019-09-29](https://github.com/graphql-rust/juniper/releases/tag/juniper-0.14.0)

- Require `url` 2.x if `url` feature is enabled.
Expand Down
11 changes: 5 additions & 6 deletions juniper/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "juniper"
version = "0.14.0"
version = "0.14.1"
authors = [
"Magnus Hallin <[email protected]>",
"Christoph Herzog <[email protected]>",
Expand Down Expand Up @@ -33,20 +33,19 @@ default = [
]

[dependencies]
juniper_codegen = { version = "0.14.0", path = "../juniper_codegen" }
juniper_codegen = { version = "0.14.1", path = "../juniper_codegen" }

async-trait = "0.1.16"
chrono = { version = "0.4.0", optional = true }
fnv = "1.0.3"
futures-preview = { version = "=0.3.0-alpha.19", optional = true }
indexmap = { version = "1.0.0", features = ["serde-1"] }
serde = { version = "1.0.8" }
serde_derive = { version = "1.0.2" }

chrono = { version = "0.4.0", optional = true }
serde_json = { version="1.0.2", optional = true }
url = { version = "2", optional = true }
uuid = { version = "0.7", optional = true }

futures-preview = { version = "=0.3.0-alpha.19", optional = true }

[dev-dependencies]
bencher = "0.1.2"
serde_json = { version = "1.0.2" }
Expand Down
2 changes: 1 addition & 1 deletion juniper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Juniper has not reached 1.0 yet, thus some API instability should be expected.
[chrono]: https://crates.io/crates/chrono

*/
#![doc(html_root_url = "https://docs.rs/juniper/0.14.0")]
#![doc(html_root_url = "https://docs.rs/juniper/0.14.1")]
#![warn(missing_docs)]

#[doc(hidden)]
Expand Down
29 changes: 5 additions & 24 deletions juniper/src/macros/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ macro_rules! __juniper_impl_trait {
}
) => {
impl<$($other,)*> $crate::$impl_trait<$crate::DefaultScalarValue> for $name {
$($body)*
$($body)+
}
};
(
Expand All @@ -26,7 +26,7 @@ macro_rules! __juniper_impl_trait {

(
impl< <$generic:tt $(: $bound: tt)*> $(, $other: tt)* > $impl_trait:tt for $name:ty {
$($body:tt)*
$($body:tt)+
}
) => {
impl<$($other,)* $generic $(: $bound)*> $crate::$impl_trait<$generic> for $name
Expand All @@ -50,17 +50,17 @@ macro_rules! __juniper_impl_trait {
$generic: $crate::ScalarValue,
for<'__b> &'__b $generic: $crate::ScalarRefValue<'__b>,
{
$($body)*
$($body)+
}
};

(
impl<$scalar:ty $(, $other: tt )*> $impl_trait:tt for $name:ty {
$($body:tt)*
$($body:tt)+
}
) => {
impl<$($other, )*> $crate::$impl_trait<$scalar> for $name {
$($body)*
$($body)+
}
};
(
Expand Down Expand Up @@ -96,25 +96,6 @@ macro_rules! __juniper_insert_generic {
};
}

// TODO: remove me.
#[doc(hidden)]
#[macro_export]
macro_rules! __juniper_extract_generic {
(<$name:ident>) => {
$name
};
(
<$generic:tt $(: $bound: tt)*>
) => {
$generic
};
(
$scalar: ty
) => {
$scalar
};
}

#[doc(hidden)]
#[macro_export]
macro_rules! __juniper_parse_object_header {
Expand Down
12 changes: 8 additions & 4 deletions juniper/src/macros/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,16 @@ macro_rules! graphql_scalar {
)
{

fn resolve_async<'a>(
fn resolve_async<'a, 'async_trait>(
&'a self,
info: &'a Self::TypeInfo,
selection_set: Option<&'a [$crate::Selection<$crate::__juniper_insert_generic!($($scalar)+)>]>,
executor: &'a $crate::Executor<Self::Context, $crate::__juniper_insert_generic!($($scalar)+)>,
) -> futures::future::BoxFuture<'a, $crate::Value<$crate::__juniper_insert_generic!($($scalar)+)>> {
selection_set: Option<&'a [$crate::Selection<'a, $crate::__juniper_insert_generic!($($scalar)+)>]>,
executor: &'a $crate::Executor<'a, Self::Context, $crate::__juniper_insert_generic!($($scalar)+)>,
) -> futures::future::BoxFuture<'async_trait, $crate::Value<$crate::__juniper_insert_generic!($($scalar)+)>>
where
'a: 'async_trait,
Self: 'async_trait,
{
use $crate::GraphQLType;
use futures::future;
let v = self.resolve(info, selection_set, executor);
Expand Down
151 changes: 77 additions & 74 deletions juniper/src/macros/tests/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,17 @@ impl Root {
0
}

// TODO: enable once [RFC 2565](https://github.com/rust-lang/rust/issues/60406) is implemented
// fn attr_arg_descr(#[doc = "The arg"] arg: i32) -> i32 { 0 }
// fn attr_arg_descr_collapse(
// #[doc = "The arg"]
// #[doc = "and more details"]
// arg: i32,
// ) -> i32 { 0 }
// TODO: enable once [this issue](https://github.com/graphql-rust/juniper/pull/441) is implemented
// fn attr_arg_descr(
// #[graphql(description = "The arg")]
// arg: i32) -> i32
// { 0 }
//
// fn attr_arg_descr_collapse(
// #[graphql(description = "The first arg")]
// #[graphql(description = "and more details")]
// arg: i32,
// ) -> i32 { 0 }

#[graphql(arguments(arg(default = 123,),))]
fn arg_with_default(arg: i32) -> i32 {
Expand Down Expand Up @@ -559,73 +563,72 @@ fn introspect_field_multi_args_descr_trailing_comma() {
});
}

// TODO: enable once [RFC 2565](https://github.com/rust-lang/rust/issues/60406) is implemented
// #[test]
// fn introspect_field_attr_arg_descr() {
// run_args_info_query("attrArgDescr", |args| {
// assert_eq!(args.len(), 1);

// assert!(args.contains(&Value::object(
// vec![
// ("name", Value::scalar("arg")),
// ("description", Value::scalar("The arg")),
// ("defaultValue", Value::null()),
// (
// "type",
// Value::object(
// vec![
// ("name", Value::null()),
// (
// "ofType",
// Value::object(
// vec![("name", Value::scalar("Int"))].into_iter().collect(),
// ),
// ),
// ]
// .into_iter()
// .collect(),
// ),
// ),
// ]
// .into_iter()
// .collect(),
// )));
// });
// }

// TODO: enable once [RFC 2565](https://github.com/rust-lang/rust/issues/60406) is implemented
// #[test]
// fn introspect_field_attr_arg_descr_collapse() {
// run_args_info_query("attrArgDescrCollapse", |args| {
// assert_eq!(args.len(), 1);

// assert!(args.contains(&Value::object(
// vec![
// ("name", Value::scalar("arg")),
// ("description", Value::scalar("The arg\nand more details")),
// ("defaultValue", Value::null()),
// (
// "type",
// Value::object(
// vec![
// ("name", Value::null()),
// (
// "ofType",
// Value::object(
// vec![("name", Value::scalar("Int"))].into_iter().collect(),
// ),
// ),
// ]
// .into_iter()
// .collect(),
// ),
// ),
// ]
// .into_iter()
// .collect(),
// )));
// });
// }
// TODO: enable once [this issue](https://github.com/graphql-rust/juniper/pull/441) is implemented
//#[test]
//fn introspect_field_attr_arg_descr() {
// run_args_info_query("attrArgDescr", |args| {
// assert_eq!(args.len(), 1);
//
// assert!(args.contains(&Value::object(
// vec![
// ("name", Value::scalar("arg")),
// ("description", Value::scalar("The arg")),
// ("defaultValue", Value::null()),
// (
// "type",
// Value::object(
// vec![
// ("name", Value::null()),
// (
// "ofType",
// Value::object(
// vec![("name", Value::scalar("Int"))].into_iter().collect(),
// ),
// ),
// ]
// .into_iter()
// .collect(),
// ),
// ),
// ]
// .into_iter()
// .collect(),
// )));
// });
//}
//
//#[test]
//fn introspect_field_attr_arg_descr_collapse() {
// run_args_info_query("attrArgDescrCollapse", |args| {
// assert_eq!(args.len(), 1);
//
// assert!(args.contains(&Value::object(
// vec![
// ("name", Value::scalar("arg")),
// ("description", Value::scalar("The arg\nand more details")),
// ("defaultValue", Value::null()),
// (
// "type",
// Value::object(
// vec![
// ("name", Value::null()),
// (
// "ofType",
// Value::object(
// vec![("name", Value::scalar("Int"))].into_iter().collect(),
// ),
// ),
// ]
// .into_iter()
// .collect(),
// ),
// ),
// ]
// .into_iter()
// .collect(),
// )));
// });
//}

#[test]
fn introspect_field_arg_with_default() {
Expand Down
3 changes: 3 additions & 0 deletions juniper/src/macros/tests/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,16 @@ impl Root {
Ok(0)
}

/*
* FIXME: make this work again
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like you need to rebase or a bad merge?

fn with_return() -> i32 {
return 0;
}

fn with_return_field_result() -> FieldResult<i32> {
return Ok(0);
}
*/
}

graphql_interface!(Interface: () |&self| {
Expand Down
Loading