Skip to content

Commit 8c16b30

Browse files
author
Joe Grund
committed
Add changelog and tests
1 parent 32c7108 commit 8c16b30

File tree

2 files changed

+39
-13
lines changed

2 files changed

+39
-13
lines changed

juniper_axum/CHANGELOG.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
`juniper_axum` changelog
2-
========================
1+
# `juniper_axum` changelog
32

43
All user visible changes to `juniper_axum` crate will be documented in this file. This project uses [Semantic Versioning 2.0.0].
54

6-
7-
8-
95
## master
106

117
### BC Breaks
@@ -16,14 +12,16 @@ All user visible changes to `juniper_axum` crate will be documented in this file
1612

1713
- Building on `wasm32-unknown-unknown` and `wasm32-wasi` targets. ([#1283], [#1282])
1814

15+
### Fixed
16+
17+
- `Content-Type` header reading full value instead of just the media type. ([#1288])
18+
1919
[#1272]: /../../pull/1272
2020
[#1282]: /../../issues/1282
2121
[#1283]: /../../pull/1283
2222

23-
24-
25-
2623
## [0.1.0] · 2024-03-20
24+
2725
[0.1.0]: /../../tree/juniper_axum-v0.1.0/juniper_axum
2826

2927
### Initialized
@@ -47,10 +45,6 @@ All user visible changes to `juniper_axum` crate will be documented in this file
4745
[#1088]: /../../pull/1088
4846
[#1184]: /../../issues/1184
4947
[#1224]: /../../pull/1224
50-
51-
52-
53-
5448
[`axum` crate]: https://docs.rs/axum
5549
[`juniper` crate]: https://docs.rs/juniper
5650
[`juniper_graphql_ws` crate]: https://docs.rs/juniper_graphql_ws
@@ -60,4 +54,4 @@ All user visible changes to `juniper_axum` crate will be documented in this file
6054
[GraphQL]: http://graphql.org
6155
[GraphQL Playground]: https://github.com/prisma/graphql-playground
6256
[MSRV]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
63-
[Semantic Versioning 2.0.0]: https://semver.org
57+
[Semantic Versioning 2.0.0]: https://semver.org

juniper_axum/src/extract.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,22 @@ mod juniper_request_tests {
248248
assert_eq!(do_from_request(req).await, expected);
249249
}
250250

251+
#[tokio::test]
252+
async fn from_json_post_request_with_charset() {
253+
let req = Request::post("/")
254+
.header("content-type", "application/json; charset=utf-8")
255+
.body(Body::from(r#"{"query": "{ add(a: 2, b: 3) }"}"#))
256+
.unwrap_or_else(|e| panic!("cannot build `Request`: {e}"));
257+
258+
let expected = JuniperRequest(GraphQLBatchRequest::Single(GraphQLRequest::new(
259+
"{ add(a: 2, b: 3) }".to_string(),
260+
None,
261+
None,
262+
)));
263+
264+
assert_eq!(do_from_request(req).await, expected);
265+
}
266+
251267
#[tokio::test]
252268
async fn from_graphql_post_request() {
253269
let req = Request::post("/")
@@ -264,6 +280,22 @@ mod juniper_request_tests {
264280
assert_eq!(do_from_request(req).await, expected);
265281
}
266282

283+
#[tokio::test]
284+
async fn from_graphql_post_request_with_charset() {
285+
let req = Request::post("/")
286+
.header("content-type", "application/graphql; charset=utf-8")
287+
.body(Body::from(r#"{ add(a: 2, b: 3) }"#))
288+
.unwrap_or_else(|e| panic!("cannot build `Request`: {e}"));
289+
290+
let expected = JuniperRequest(GraphQLBatchRequest::Single(GraphQLRequest::new(
291+
"{ add(a: 2, b: 3) }".to_string(),
292+
None,
293+
None,
294+
)));
295+
296+
assert_eq!(do_from_request(req).await, expected);
297+
}
298+
267299
/// Performs [`JuniperRequest::from_request()`].
268300
async fn do_from_request(req: Request<Body>) -> JuniperRequest {
269301
match JuniperRequest::from_request(req, &()).await {

0 commit comments

Comments
 (0)