Skip to content

Commit d666343

Browse files
committed
Make it lint
1 parent 227a9b9 commit d666343

26 files changed

+78
-76
lines changed

juniper/src/schema/translate/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use crate::{ScalarValue, SchemaType};
22

3-
#[cfg_attr(not(feature = "schema-language"), allow(dead_code))]
3+
#[cfg_attr(
4+
not(feature = "schema-language"),
5+
expect(dead_code, reason = "common abstraction")
6+
)]
47
pub trait SchemaTranslator<'a, T> {
58
fn translate_schema<S: 'a + ScalarValue>(s: &'a SchemaType<S>) -> T;
69
}

juniper_axum/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
#![cfg_attr(any(doc, test), doc = include_str!("../README.md"))]
33
#![cfg_attr(not(any(doc, test)), doc = env!("CARGO_PKG_NAME"))]
44

5+
// TODO: Try remove on upgrade of `axum` crate.
6+
mod for_minimal_versions_check_only {
7+
use bytes as _;
8+
}
9+
510
pub mod extract;
611
pub mod response;
712
#[cfg(feature = "subscriptions")]

juniper_hyper/src/lib.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ use juniper::{
1616
use serde_json::error::Error as SerdeError;
1717
use url::form_urlencoded;
1818

19+
/// Executes synchronously the provided GraphQL [`Request`] against the provided `schema` in the
20+
/// provided `context`, returning the encoded [`Response`].
1921
pub async fn graphql_sync<CtxT, QueryT, MutationT, SubscriptionT, S, B>(
20-
root_node: Arc<RootNode<'static, QueryT, MutationT, SubscriptionT, S>>,
22+
schema: Arc<RootNode<'static, QueryT, MutationT, SubscriptionT, S>>,
2123
context: Arc<CtxT>,
2224
req: Request<B>,
2325
) -> Response<String>
@@ -33,13 +35,15 @@ where
3335
B: Body<Error: fmt::Display>,
3436
{
3537
match parse_req(req).await {
36-
Ok(req) => execute_request_sync(root_node, context, req).await,
38+
Ok(req) => execute_request_sync(schema, context, req).await,
3739
Err(resp) => resp,
3840
}
3941
}
4042

43+
/// Executes the provided GraphQL [`Request`] against the provided `schema` in the provided
44+
/// `context`, returning the encoded [`Response`].
4145
pub async fn graphql<CtxT, QueryT, MutationT, SubscriptionT, S, B>(
42-
root_node: Arc<RootNode<'static, QueryT, MutationT, SubscriptionT, S>>,
46+
schema: Arc<RootNode<'static, QueryT, MutationT, SubscriptionT, S>>,
4347
context: Arc<CtxT>,
4448
req: Request<B>,
4549
) -> Response<String>
@@ -55,7 +59,7 @@ where
5559
B: Body<Error: fmt::Display>,
5660
{
5761
match parse_req(req).await {
58-
Ok(req) => execute_request(root_node, context, req).await,
62+
Ok(req) => execute_request(schema, context, req).await,
5963
Err(resp) => resp,
6064
}
6165
}
@@ -137,6 +141,11 @@ where
137141
)))
138142
}
139143

144+
/// Generates a [`Response`] page containing [GraphiQL].
145+
///
146+
/// This does not handle routing, so you can mount it on any endpoint.
147+
///
148+
/// [GraphiQL]: https://github.com/graphql/graphiql
140149
pub async fn graphiql(
141150
graphql_endpoint: &str,
142151
subscriptions_endpoint: Option<&str>,
@@ -148,6 +157,11 @@ pub async fn graphiql(
148157
resp
149158
}
150159

160+
/// Generates a [`Response`] page containing [GraphQL Playground].
161+
///
162+
/// This does not handle routing, so you can mount it on any endpoint.
163+
///
164+
/// [GraphQL Playground]: https://github.com/prisma/graphql-playground
151165
pub async fn playground(
152166
graphql_endpoint: &str,
153167
subscriptions_endpoint: Option<&str>,
@@ -168,7 +182,7 @@ where
168182
}
169183

170184
async fn execute_request_sync<CtxT, QueryT, MutationT, SubscriptionT, S>(
171-
root_node: Arc<RootNode<'static, QueryT, MutationT, SubscriptionT, S>>,
185+
schema: Arc<RootNode<'static, QueryT, MutationT, SubscriptionT, S>>,
172186
context: Arc<CtxT>,
173187
request: GraphQLBatchRequest<S>,
174188
) -> Response<String>
@@ -182,7 +196,7 @@ where
182196
CtxT: Sync,
183197
S: ScalarValue + Send + Sync,
184198
{
185-
let res = request.execute_sync(&*root_node, &context);
199+
let res = request.execute_sync(&*schema, &context);
186200
let body = serde_json::to_string_pretty(&res).unwrap();
187201
let code = if res.is_ok() {
188202
StatusCode::OK
@@ -199,7 +213,7 @@ where
199213
}
200214

201215
async fn execute_request<CtxT, QueryT, MutationT, SubscriptionT, S>(
202-
root_node: Arc<RootNode<'static, QueryT, MutationT, SubscriptionT, S>>,
216+
schema: Arc<RootNode<'static, QueryT, MutationT, SubscriptionT, S>>,
203217
context: Arc<CtxT>,
204218
request: GraphQLBatchRequest<S>,
205219
) -> Response<String>
@@ -213,7 +227,7 @@ where
213227
CtxT: Sync,
214228
S: ScalarValue + Send + Sync,
215229
{
216-
let res = request.execute(&*root_node, &context).await;
230+
let res = request.execute(&*schema, &context).await;
217231
let body = serde_json::to_string_pretty(&res).unwrap();
218232
let code = if res.is_ok() {
219233
StatusCode::OK

juniper_warp/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ futures = { version = "0.3.22", optional = true }
3434
juniper = { version = "0.16", path = "../juniper", default-features = false }
3535
juniper_graphql_ws = { version = "0.4.0", path = "../juniper_graphql_ws", features = ["graphql-transport-ws", "graphql-ws"], optional = true }
3636
log = { version = "0.4", optional = true }
37-
serde = { version = "1.0.122", features = ["derive"] }
3837
serde_json = "1.0.18"
39-
thiserror = "2.0"
4038
tokio = { version = "1.0", features = ["rt"] }
4139
warp = { version = "0.3.2", default-features = false }
4240

juniper_warp/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
#![cfg_attr(docsrs, feature(doc_cfg))]
44
#![deny(missing_docs)]
55

6+
// TODO: Try remove on upgrade of `warp` crate.
7+
mod for_minimal_versions_check_only {
8+
use headers as _;
9+
}
10+
611
mod response;
712
#[cfg(feature = "subscriptions")]
813
pub mod subscriptions;

tests/integration/Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ edition = "2024"
55
publish = false
66

77
[dev-dependencies]
8-
async-trait = "0.1.39"
98
chrono = { version = "0.4", default-features = false }
10-
derive_more = { version = "2.0", features = ["from"] }
11-
fnv = "1.0"
129
futures = "0.3"
1310
itertools = "0.14"
1411
juniper = { path = "../../juniper", features = ["chrono"] }
@@ -24,7 +21,5 @@ allow_attributes_without_reason = "warn"
2421
closure_returning_async_block = "warn"
2522
future_incompatible = { level = "warn", priority = -1 }
2623
impl_trait_redundant_captures = "warn"
27-
missing_docs = "warn"
2824
non_ascii_idents = "forbid"
2925
unsafe_code = "forbid"
30-
unused_crate_dependencies = "warn"

tests/integration/tests/codegen_enum_derive.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use juniper::{
1010
use self::common::util::{schema, schema_with_scalar};
1111

1212
// Override `std::prelude` items to check whether macros expand hygienically.
13-
#[allow(unused_imports)]
1413
use self::common::hygiene::*;
1514

1615
mod trivial {
@@ -125,7 +124,6 @@ mod ignored_variant {
125124
#[derive(GraphQLEnum)]
126125
enum Character {
127126
Human,
128-
#[allow(dead_code)]
129127
#[graphql(ignore)]
130128
Droid,
131129
}
@@ -210,7 +208,7 @@ mod ignored_generic_variant {
210208
enum Character<T> {
211209
Human,
212210
Droid,
213-
#[allow(dead_code)]
211+
#[expect(dead_code, reason = "GraphQL schema testing")]
214212
#[graphql(ignore)]
215213
Ignored(T),
216214
}
@@ -390,7 +388,7 @@ mod description_from_doc_comment {
390388
}
391389

392390
mod deprecation_from_attr {
393-
#![allow(deprecated)]
391+
#![expect(deprecated, reason = "GraphQL schema testing")]
394392

395393
use super::*;
396394

@@ -492,8 +490,6 @@ mod deprecation_from_attr {
492490
}
493491

494492
mod deprecation_from_graphql_attr {
495-
#![allow(deprecated)]
496-
497493
use super::*;
498494

499495
/// Character doc.
@@ -594,7 +590,7 @@ mod deprecation_from_graphql_attr {
594590
}
595591

596592
mod explicit_name_description_and_deprecation {
597-
#![allow(deprecated)]
593+
#![expect(deprecated, reason = "GraphQL schema testing")]
598594

599595
use super::*;
600596

@@ -834,7 +830,7 @@ mod explicit_generic_scalar {
834830
enum Character<S: ScalarValue> {
835831
Human,
836832
Droid,
837-
#[allow(dead_code)]
833+
#[expect(dead_code, reason = "GraphQL schema testing")]
838834
#[graphql(ignore)]
839835
Scalar(S),
840836
}
@@ -900,7 +896,7 @@ mod bounded_generic_scalar {
900896
mod explicit_custom_context {
901897
use super::*;
902898

903-
struct CustomContext(#[allow(dead_code)] prelude::String);
899+
struct CustomContext(#[expect(dead_code, reason = "GraphQL schema testing")] prelude::String);
904900

905901
impl juniper::Context for CustomContext {}
906902

tests/integration/tests/codegen_input_object_derive.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use juniper::{
1010
use self::common::util::schema;
1111

1212
// Override `std::prelude` items to check whether macros expand hygienically.
13-
#[allow(unused_imports)]
1413
use self::common::hygiene::*;
1514

1615
mod trivial {

tests/integration/tests/codegen_interface_attr_struct.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use juniper::{
1010
use self::common::util::{schema, schema_with_scalar};
1111

1212
// Override `std::prelude` items to check whether macros expand hygienically.
13-
#[allow(unused_imports)]
1413
use self::common::hygiene::*;
1514

1615
mod no_implers {
@@ -2234,7 +2233,7 @@ mod field_return_union_subtyping {
22342233
value: i32,
22352234
}
22362235

2237-
#[allow(dead_code)]
2236+
#[expect(dead_code, reason = "GraphQL schema testing")]
22382237
#[derive(GraphQLUnion)]
22392238
enum KeyFeature {
22402239
Strength(Strength),
@@ -3063,7 +3062,7 @@ mod branching_subtyping {
30633062
mod preserves_visibility {
30643063
use super::*;
30653064

3066-
#[allow(dead_code)]
3065+
#[expect(dead_code, reason = "GraphQL schema testing")]
30673066
type Foo = self::inner::CharacterValue;
30683067

30693068
pub(crate) mod inner {

tests/integration/tests/codegen_interface_attr_trait.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Tests for `#[graphql_interface]` macro placed on a trait.
22
3-
#![allow(dead_code)]
3+
#![expect(dead_code, reason = "GraphQL schema definition")]
44
// Assert that `#[graphql_interface]` macro placed on a trait stops Clippy from enforcing `# Errors`
55
// and `# Panics` sections in GraphQL descriptions.
66
#![deny(clippy::missing_errors_doc, clippy::missing_panics_doc)]
@@ -16,7 +16,6 @@ use juniper::{
1616
use self::common::util::{schema, schema_with_scalar};
1717

1818
// Override `std::prelude` items to check whether macros expand hygienically.
19-
#[allow(unused_imports)]
2019
use self::common::hygiene::*;
2120

2221
mod no_implers {
@@ -2367,7 +2366,7 @@ mod explicit_custom_context {
23672366

23682367
#[graphql_object(impl = CharacterValue, context = CustomContext)]
23692368
impl Droid {
2370-
#[allow(clippy::needless_lifetimes)] // intentionally
2369+
#[expect(clippy::needless_lifetimes, reason = "intentional")]
23712370
async fn id<'a>(&'a self) -> &'a str {
23722371
&self.id
23732372
}
@@ -2376,7 +2375,7 @@ mod explicit_custom_context {
23762375
&self.primary_function
23772376
}
23782377

2379-
#[allow(clippy::needless_lifetimes)] // intentionally
2378+
#[expect(clippy::needless_lifetimes, reason = "intentional")]
23802379
async fn info<'b>(&'b self) -> &'b str {
23812380
&self.primary_function
23822381
}
@@ -2675,7 +2674,7 @@ mod executor {
26752674
&self.home_planet
26762675
}
26772676

2678-
#[allow(clippy::needless_lifetimes)] // intentionally
2677+
#[expect(clippy::needless_lifetimes, reason = "intentional")]
26792678
async fn info<'b>(&'b self, _arg: prelude::Option<i32>) -> &'b str {
26802679
&self.home_planet
26812680
}
@@ -3068,7 +3067,7 @@ mod field_return_union_subtyping {
30683067
value: i32,
30693068
}
30703069

3071-
#[allow(dead_code)]
3070+
#[expect(dead_code, reason = "GraphQL schema testing")]
30723071
#[derive(GraphQLUnion)]
30733072
enum KeyFeature {
30743073
Strength(Strength),
@@ -3898,7 +3897,7 @@ mod branching_subtyping {
38983897
mod preserves_visibility {
38993898
use super::*;
39003899

3901-
#[allow(dead_code)]
3900+
#[expect(dead_code, reason = "GraphQL schema testing")]
39023901
type Foo = self::inner::CharacterValue;
39033902

39043903
pub(crate) mod inner {

0 commit comments

Comments
 (0)