Skip to content

Commit 4ef8cf7

Browse files
authored
Fix Rejection handling in juniper_warp filters (#1222, #1177)
- rework `make_graphql_filter()` and `make_graphql_filter_sync()` to execute `context_extractor` only once - handle all non-recoverable `Rejection`s in `make_graphql_filter()` and `make_graphql_filter_sync()` - relax requirement for `context_extractor` to be a `BoxedFilter` only - remove `JoinError` from public API - provide example of fallible `context_extractor` in `make_graphql_filter()` API docs Additionally: - split `juniper_warp` modules into separate files - add @tyranron as `juniper_warp` co-author
1 parent 904d9cd commit 4ef8cf7

File tree

8 files changed

+1054
-794
lines changed

8 files changed

+1054
-794
lines changed

juniper_warp/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ All user visible changes to `juniper_warp` crate will be documented in this file
1111
### BC Breaks
1212

1313
- Switched to 0.16 version of [`juniper` crate].
14+
- Removed `JoinError` from public API. ([#1222], [#1177])
1415

1516
### Added
1617

@@ -20,11 +21,18 @@ All user visible changes to `juniper_warp` crate will be documented in this file
2021
### Changed
2122

2223
- Made `schema` argument of `make_graphql_filter()` and `make_graphql_filter_sync()` polymorphic, allowing to specify external `Arc`ed `schema`. ([#1136], [#1135])
24+
- Relaxed requirement for `context_extractor` to be a `BoxedFilter` only. ([#1222], [#1177])
25+
26+
### Fixed
27+
28+
- Excessive `context_extractor` execution in `make_graphql_filter()` and `make_graphql_filter_sync()`. ([#1222], [#1177])
2329

2430
[#1135]: /../../issues/1136
2531
[#1136]: /../../pull/1136
2632
[#1158]: /../../pull/1158
33+
[#1177]: /../../issues/1177
2734
[#1191]: /../../pull/1191
35+
[#1222]: /../../pull/1222
2836

2937

3038

juniper_warp/Cargo.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ edition = "2021"
55
rust-version = "1.73"
66
description = "`juniper` GraphQL integration with `warp`."
77
license = "BSD-2-Clause"
8-
authors = ["Tom Houlé <[email protected]>"]
8+
authors = [
9+
"Tom Houlé <[email protected]>",
10+
"Kai Ren <[email protected]>",
11+
]
912
documentation = "https://docs.rs/juniper_warp"
1013
homepage = "https://github.com/graphql-rust/juniper/tree/master/juniper_warp"
1114
repository = "https://github.com/graphql-rust/juniper"
@@ -20,21 +23,21 @@ rustdoc-args = ["--cfg", "docsrs"]
2023

2124
[features]
2225
subscriptions = [
26+
"dep:futures",
2327
"dep:juniper_graphql_ws",
2428
"dep:log",
2529
"warp/websocket",
2630
]
2731

2832
[dependencies]
29-
anyhow = "1.0.47"
30-
futures = "0.3.22"
33+
futures = { version = "0.3.22", optional = true }
3134
juniper = { version = "0.16.0-dev", path = "../juniper", default-features = false }
3235
juniper_graphql_ws = { version = "0.4.0-dev", path = "../juniper_graphql_ws", features = ["graphql-transport-ws", "graphql-ws"], optional = true }
3336
log = { version = "0.4", optional = true }
3437
serde = { version = "1.0.122", features = ["derive"] }
3538
serde_json = "1.0.18"
3639
thiserror = "1.0"
37-
tokio = { version = "1.0", features = ["rt-multi-thread"] }
40+
tokio = { version = "1.0", features = ["rt"] }
3841
warp = { version = "0.3.2", default-features = false }
3942

4043
# Fixes for `minimal-versions` check.
@@ -44,6 +47,7 @@ headers = "0.3.8"
4447
[dev-dependencies]
4548
async-stream = "0.3"
4649
env_logger = "0.10"
50+
futures = "0.3.22"
4751
juniper = { version = "0.16.0-dev", path = "../juniper", features = ["expose-test-schema"] }
4852
log = "0.4"
4953
percent-encoding = "2.1"

juniper_warp/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 2-Clause License
22

3-
Copyright (c) 2018-2022, Tom Houlé
3+
Copyright (c) 2018-2023, Tom Houlé, Kai Ren
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

juniper_warp/examples/subscription.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ async fn main() {
160160
.and(warp::path("graphql"))
161161
.and(juniper_warp::make_graphql_filter(
162162
schema.clone(),
163-
warp::any().map(|| Context).boxed(),
163+
warp::any().map(|| Context),
164164
)))
165165
.or(
166166
warp::path("subscriptions").and(juniper_warp::subscriptions::make_ws_filter(

0 commit comments

Comments
 (0)