Skip to content

Commit 3e50adf

Browse files
committed
Merge branch 'master' into object-safe-graphqltype
2 parents 8f5c5ca + a08ce07 commit 3e50adf

File tree

4 files changed

+23
-31
lines changed

4 files changed

+23
-31
lines changed

docs/book/content/types/scalars.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Juniper has built-in support for:
2727
spec](http://facebook.github.io/graphql/#sec-ID) as a type that is serialized
2828
as a string but can be parsed from both a string and an integer.
2929

30+
Note that there is no built-in support for `i64`/`u64`, as the GraphQL spec [doesn't define any built-in scalars for `i64`/`u64` by default](https://spec.graphql.org/June2018/#sec-Int). You may wish to leverage a [custom GraphQL scalar](#custom-scalars) in your schema to support them.
31+
3032
**Third party types**:
3133

3234
Juniper has built-in support for a few additional types from common third party

juniper_rocket_async/examples/rocket_server.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ fn post_graphql_handler(
3232
request.execute_sync(&schema, &context)
3333
}
3434

35-
fn main() {
35+
#[rocket::main]
36+
async fn main() {
3637
rocket::ignite()
3738
.manage(Database::new())
3839
.manage(Schema::new(
@@ -45,5 +46,6 @@ fn main() {
4546
rocket::routes![graphiql, get_graphql_handler, post_graphql_handler],
4647
)
4748
.launch()
49+
.await
4850
.expect("server to launch");
4951
}

juniper_rocket_async/src/lib.rs

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -325,25 +325,15 @@ where
325325
}
326326
}
327327

328-
use rocket::futures::future::BoxFuture;
329-
330-
impl<'r> Responder<'r> for GraphQLResponse {
331-
fn respond_to<'a, 'x>(self, _req: &'r Request<'a>) -> BoxFuture<'x, response::Result<'r>>
332-
where
333-
'a: 'x,
334-
'r: 'x,
335-
Self: 'x,
336-
{
328+
impl<'r, 'o: 'r> Responder<'r, 'o> for GraphQLResponse {
329+
fn respond_to(self, _req: &'r Request<'_>) -> response::Result<'o> {
337330
let GraphQLResponse(status, body) = self;
338331

339-
Box::pin(async move {
340-
Ok(Response::build()
341-
.header(ContentType::new("application", "json"))
342-
.status(status)
343-
.sized_body(Cursor::new(body))
344-
.await
345-
.finalize())
346-
})
332+
Response::build()
333+
.header(ContentType::new("application", "json"))
334+
.status(status)
335+
.sized_body(body.len(), Cursor::new(body))
336+
.ok()
347337
}
348338
}
349339

@@ -528,10 +518,10 @@ mod tests {
528518
}
529519
}
530520

531-
#[test]
532-
fn test_rocket_integration() {
521+
#[tokio::test]
522+
async fn test_rocket_integration() {
533523
let rocket = make_rocket();
534-
let client = Client::new(rocket).expect("valid rocket");
524+
let client = Client::new(rocket).await.expect("valid rocket");
535525
let integration = TestRocketIntegration { client };
536526

537527
http_tests::run_http_test_suite(&integration);
@@ -551,7 +541,7 @@ mod tests {
551541

552542
let rocket = make_rocket_without_routes()
553543
.mount("/", routes![post_graphql_assert_operation_name_handler]);
554-
let client = Client::new(rocket).expect("valid rocket");
544+
let client = Client::new(rocket).await.expect("valid rocket");
555545

556546
let resp = client
557547
.post("/")
@@ -583,14 +573,13 @@ mod tests {
583573
.expect("No content type header from handler")
584574
.to_string();
585575
let body = response
586-
.body()
587-
.expect("No body returned from GraphQL handler")
588-
.into_string()
589-
.await;
576+
.body_string()
577+
.await
578+
.expect("No body returned from GraphQL handler");
590579

591580
http_tests::TestResponse {
592581
status_code,
593-
body,
582+
body: Some(body),
594583
content_type,
595584
}
596585
}

juniper_subscriptions/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ where
187187
ready_vec.push(None);
188188
}
189189

190-
let stream = futures::stream::poll_fn(
191-
move |mut ctx| -> Poll<Option<GraphQLResponse<'static, S>>> {
190+
let stream =
191+
futures::stream::poll_fn(move |mut ctx| -> Poll<Option<GraphQLResponse<'a, S>>> {
192192
let mut obj_iterator = object.iter_mut();
193193

194194
// Due to having to modify `ready_vec` contents (by-move pattern)
@@ -246,8 +246,7 @@ where
246246
} else {
247247
Poll::Pending
248248
}
249-
},
250-
);
249+
});
251250

252251
Box::pin(stream)
253252
}

0 commit comments

Comments
 (0)