Skip to content

Commit

Permalink
Add changelog and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jgrund committed Oct 25, 2024
1 parent 32c7108 commit 8c16b30
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
20 changes: 7 additions & 13 deletions juniper_axum/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
`juniper_axum` changelog
========================
# `juniper_axum` changelog

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




## master

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

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

### Fixed

- `Content-Type` header reading full value instead of just the media type. ([#1288])

[#1272]: /../../pull/1272
[#1282]: /../../issues/1282
[#1283]: /../../pull/1283




## [0.1.0] · 2024-03-20

[0.1.0]: /../../tree/juniper_axum-v0.1.0/juniper_axum

### Initialized
Expand All @@ -47,10 +45,6 @@ All user visible changes to `juniper_axum` crate will be documented in this file
[#1088]: /../../pull/1088
[#1184]: /../../issues/1184
[#1224]: /../../pull/1224




[`axum` crate]: https://docs.rs/axum
[`juniper` crate]: https://docs.rs/juniper
[`juniper_graphql_ws` crate]: https://docs.rs/juniper_graphql_ws
Expand All @@ -60,4 +54,4 @@ All user visible changes to `juniper_axum` crate will be documented in this file
[GraphQL]: http://graphql.org
[GraphQL Playground]: https://github.com/prisma/graphql-playground
[MSRV]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
[Semantic Versioning 2.0.0]: https://semver.org
[Semantic Versioning 2.0.0]: https://semver.org
32 changes: 32 additions & 0 deletions juniper_axum/src/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,22 @@ mod juniper_request_tests {
assert_eq!(do_from_request(req).await, expected);
}

#[tokio::test]
async fn from_json_post_request_with_charset() {
let req = Request::post("/")
.header("content-type", "application/json; charset=utf-8")
.body(Body::from(r#"{"query": "{ add(a: 2, b: 3) }"}"#))
.unwrap_or_else(|e| panic!("cannot build `Request`: {e}"));

let expected = JuniperRequest(GraphQLBatchRequest::Single(GraphQLRequest::new(
"{ add(a: 2, b: 3) }".to_string(),
None,
None,
)));

assert_eq!(do_from_request(req).await, expected);
}

#[tokio::test]
async fn from_graphql_post_request() {
let req = Request::post("/")
Expand All @@ -264,6 +280,22 @@ mod juniper_request_tests {
assert_eq!(do_from_request(req).await, expected);
}

#[tokio::test]
async fn from_graphql_post_request_with_charset() {
let req = Request::post("/")
.header("content-type", "application/graphql; charset=utf-8")
.body(Body::from(r#"{ add(a: 2, b: 3) }"#))
.unwrap_or_else(|e| panic!("cannot build `Request`: {e}"));

let expected = JuniperRequest(GraphQLBatchRequest::Single(GraphQLRequest::new(
"{ add(a: 2, b: 3) }".to_string(),
None,
None,
)));

assert_eq!(do_from_request(req).await, expected);
}

/// Performs [`JuniperRequest::from_request()`].
async fn do_from_request(req: Request<Body>) -> JuniperRequest {
match JuniperRequest::from_request(req, &()).await {
Expand Down

0 comments on commit 8c16b30

Please sign in to comment.