File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ A typed GraphQL client library for Rust.
59
59
``` rust
60
60
use graphql_client :: {GraphQLQuery , Response };
61
61
use std :: error :: Error ;
62
+ use reqwest;
62
63
63
64
#[derive(GraphQLQuery )]
64
65
#[graphql(
@@ -68,14 +69,14 @@ A typed GraphQL client library for Rust.
68
69
)]
69
70
pub struct UnionQuery ;
70
71
71
- fn perform_my_query (variables : union_query :: Variables ) -> Result <(), Box <dyn Error >> {
72
+ async fn perform_my_query (variables : union_query :: Variables ) -> Result <(), Box <dyn Error >> {
72
73
73
74
// this is the important line
74
75
let request_body = UnionQuery :: build_query (variables );
75
76
76
77
let client = reqwest :: Client :: new ();
77
- let mut res = client . post (" /graphql" ). json (& request_body ). send ()? ;
78
- let response_body : Response <union_query :: ResponseData > = res . json ()? ;
78
+ let mut res = client . post (" /graphql" ). json (& request_body ). send (). await ? ;
79
+ let response_body : Response <union_query :: ResponseData > = res . json (). await ? ;
79
80
println! (" {:#?}" , response_body );
80
81
Ok (())
81
82
}
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ optional = true
41
41
[dev-dependencies ]
42
42
# Note: If we bumpup wasm-bindge-test version, we should change CI setting.
43
43
wasm-bindgen-test = " ^0.3"
44
+ reqwest = { version = " ^0.10" , features = [" json" , " blocking" ] }
44
45
45
46
[features ]
46
47
default = [" graphql_query_derive" ]
You can’t perform that action at this time.
0 commit comments