Allow to specify already Arced schema in juniper_warp (#1136, #1135)

Co-authored-by: Kai Ren <tyranron@gmail.com>
This commit is contained in:
Darin Morrison 2023-01-20 12:15:35 -07:00 committed by GitHub
parent 9ae0c89537
commit 9e0b9692a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -12,6 +12,13 @@ All user visible changes to `juniper_warp` crate will be documented in this file
- Switched to 0.16 version of [`juniper` crate].
### Changed
- Made `schema` argument of `make_graphql_filter()` and `make_graphql_filter_sync()` polymorphic, allowing to specify external `Arc`ed `schema`. ([#1136], [#1135])
[#1135]: /../../issues/1136
[#1136]: /../../pull/1136

View file

@ -70,7 +70,7 @@ use warp::{body, filters::BoxedFilter, http, hyper::body::Bytes, query, Filter};
/// .and(graphql_filter);
/// ```
pub fn make_graphql_filter<Query, Mutation, Subscription, CtxT, S>(
schema: juniper::RootNode<'static, Query, Mutation, Subscription, S>,
schema: impl Into<Arc<juniper::RootNode<'static, Query, Mutation, Subscription, S>>>,
context_extractor: BoxedFilter<(CtxT,)>,
) -> BoxedFilter<(http::Response<Vec<u8>>,)>
where
@ -83,7 +83,7 @@ where
CtxT: Send + Sync + 'static,
S: ScalarValue + Send + Sync + 'static,
{
let schema = Arc::new(schema);
let schema = schema.into();
let post_json_schema = schema.clone();
let post_graphql_schema = schema.clone();
@ -155,7 +155,7 @@ where
/// Make a synchronous filter for graphql endpoint.
pub fn make_graphql_filter_sync<Query, Mutation, Subscription, CtxT, S>(
schema: juniper::RootNode<'static, Query, Mutation, Subscription, S>,
schema: impl Into<Arc<juniper::RootNode<'static, Query, Mutation, Subscription, S>>>,
context_extractor: BoxedFilter<(CtxT,)>,
) -> BoxedFilter<(http::Response<Vec<u8>>,)>
where
@ -165,7 +165,7 @@ where
CtxT: Send + Sync + 'static,
S: ScalarValue + Send + Sync + 'static,
{
let schema = Arc::new(schema);
let schema = schema.into();
let post_json_schema = schema.clone();
let post_graphql_schema = schema.clone();