Skip to content

Commit

Permalink
Switch to 2024 Rust edition
Browse files Browse the repository at this point in the history
- bump up MSRV to 1.85
- tune lints for 1.85 Rust
  • Loading branch information
tyranron committed Feb 24, 2025
1 parent 66b19fa commit 1b1fc61
Show file tree
Hide file tree
Showing 215 changed files with 799 additions and 788 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,25 +145,21 @@ jobs:
strategy:
fail-fast: false
matrix:
msrv: ["1.75.0"]
msrv: ["1.85.0"]
crate:
- juniper_codegen
- juniper
- juniper_subscriptions
- juniper_graphql_ws
- juniper_actix
- juniper_axum
#- juniper_hyper
- juniper_hyper
- juniper_rocket
- juniper_warp
os:
- ubuntu
- macOS
- windows
include:
- { msrv: "1.79.0", crate: "juniper_hyper", os: "ubuntu" }
- { msrv: "1.79.0", crate: "juniper_hyper", os: "macOS" }
- { msrv: "1.79.0", crate: "juniper_hyper", os: "windows" }
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion benches/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "juniper_benchmarks"
version = "0.0.0"
edition = "2021"
edition = "2024"
authors = ["Christoph Herzog <[email protected]>"]
publish = false

Expand Down
2 changes: 1 addition & 1 deletion benches/benches/benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};

use juniper::InputValue;
use juniper_benchmarks as j;
Expand Down
4 changes: 2 additions & 2 deletions benches/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use juniper::{
graphql_object, DefaultScalarValue, EmptyMutation, EmptySubscription, ExecutionError,
FieldError, GraphQLEnum, GraphQLObject, RootNode, Value, Variables,
DefaultScalarValue, EmptyMutation, EmptySubscription, ExecutionError, FieldError, GraphQLEnum,
GraphQLObject, RootNode, Value, Variables, graphql_object,
};

pub type QueryResult = Result<
Expand Down
2 changes: 1 addition & 1 deletion book/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ create-missing = false
git_repository_url = "https://github.com/graphql-rust/juniper"

[rust]
edition = "2021"
edition = "2024"
2 changes: 1 addition & 1 deletion book/src/advanced/dataloader.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Let's remake our [example of N+1 problem](n_plus_1.md), so it's solved by applyi
# use std::{collections::HashMap, sync::Arc};
# use anyhow::anyhow;
# use dataloader::non_cached::Loader;
# use juniper::{graphql_object, GraphQLObject};
# use juniper::{GraphQLObject, graphql_object};
#
# type CultId = i32;
# type UserId = i32;
Expand Down
2 changes: 1 addition & 1 deletion book/src/advanced/implicit_and_explicit_null.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The last two cases rely on being able to distinguish between [explicit and impli
Unfortunately, plain `Option` is not capable to distinguish them. That's why in [Juniper], this can be done using the [`Nullable`] type:
```rust
# extern crate juniper;
use juniper::{graphql_object, FieldResult, GraphQLInputObject, Nullable};
use juniper::{FieldResult, GraphQLInputObject, Nullable, graphql_object};

#[derive(GraphQLInputObject)]
struct UserPatchInput {
Expand Down
2 changes: 1 addition & 1 deletion book/src/advanced/lookahead.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ In [GraphQL], look-ahead machinery allows us to introspect the currently [execut
In [Juniper], it's represented by the [`Executor::look_ahead()`][20] method.
```rust
# extern crate juniper;
# use juniper::{graphql_object, Executor, GraphQLObject, ScalarValue};
# use juniper::{Executor, GraphQLObject, ScalarValue, graphql_object};
#
# type UserId = i32;
#
Expand Down
2 changes: 1 addition & 1 deletion book/src/advanced/n_plus_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A common issue with [GraphQL] server implementations is how the [resolvers][2] q
# extern crate anyhow;
# extern crate juniper;
# use anyhow::anyhow;
# use juniper::{graphql_object, GraphQLObject};
# use juniper::{GraphQLObject, graphql_object};
#
# type CultId = i32;
# type UserId = i32;
Expand Down
8 changes: 4 additions & 4 deletions book/src/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ For more advanced mappings, [Juniper] provides multiple macros to map your [Rust
# use std::fmt::Display;
#
use juniper::{
graphql_object, EmptySubscription, FieldResult, GraphQLEnum,
GraphQLInputObject, GraphQLObject, ScalarValue,
EmptySubscription, FieldResult, GraphQLEnum, GraphQLInputObject,
GraphQLObject, ScalarValue, graphql_object,
};
#
# struct DatabasePool;
Expand Down Expand Up @@ -162,8 +162,8 @@ To actually serve the [schema], see the guides for our various [server integrati
# // Only needed due to 2018 edition because the macro is not accessible.
# #[macro_use] extern crate juniper;
use juniper::{
graphql_object, graphql_value, EmptyMutation, EmptySubscription,
GraphQLEnum, Variables,
EmptyMutation, EmptySubscription, GraphQLEnum, Variables,
graphql_object, graphql_value,
};

#[derive(GraphQLEnum, Clone, Copy)]
Expand Down
2 changes: 1 addition & 1 deletion book/src/schema/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Both [query][1] and [mutation][2] objects are regular [GraphQL objects][4], defi
```rust
# extern crate juniper;
# use juniper::{
# graphql_object, EmptySubscription, FieldResult, GraphQLObject, RootNode,
# EmptySubscription, FieldResult, GraphQLObject, RootNode, graphql_object,
# };
#
#[derive(GraphQLObject)]
Expand Down
4 changes: 2 additions & 2 deletions book/src/schema/introspection.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Because [introspection][0] queries are just regular [GraphQL queries][2], [Junip
```rust
# extern crate juniper;
# use juniper::{
# graphql_object, graphql_vars, EmptyMutation, EmptySubscription, GraphQLError,
# RootNode,
# EmptyMutation, EmptySubscription, GraphQLError, RootNode,
# graphql_object, graphql_vars,
# };
#
pub struct Query;
Expand Down
2 changes: 1 addition & 1 deletion book/src/schema/subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The [subscription root][3] is just a [GraphQL object][4], similar to the [query
# extern crate juniper;
# use std::pin::Pin;
# use futures::Stream;
# use juniper::{graphql_object, graphql_subscription, FieldError};
# use juniper::{FieldError, graphql_object, graphql_subscription};
#
# #[derive(Clone)]
# pub struct Database;
Expand Down
2 changes: 1 addition & 1 deletion book/src/types/input_objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ In [Juniper], defining a [GraphQL input object][0] is quite straightforward and
```rust
# #![allow(unused_variables)]
# extern crate juniper;
# use juniper::{graphql_object, GraphQLInputObject, GraphQLObject};
# use juniper::{GraphQLInputObject, GraphQLObject, graphql_object};
#
#[derive(GraphQLInputObject)]
struct Coordinate {
Expand Down
2 changes: 1 addition & 1 deletion book/src/types/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ That's why [Juniper] takes the following approach to represent [GraphQL interfac
This may be done by using either the [`#[graphql_interface]` attribute][3] or the [`#[derive(GraphQLInterface)]`][2]:
```rust
# extern crate juniper;
# use juniper::{graphql_interface, GraphQLInterface, GraphQLObject};
# use juniper::{GraphQLInterface, GraphQLObject, graphql_interface};
#
// By default a `CharacterValue` enum is generated by macro to represent
// values of this GraphQL interface.
Expand Down
2 changes: 1 addition & 1 deletion book/src/types/objects/complex_fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Using a plain [Rust struct][struct] for representing a [GraphQL object][0] is ea
To support these more complicated use cases, we need a way to define a [GraphQL field][4] as a function. In [Juniper] this is achievable by placing the [`#[graphql_object]` attribute][3] on an [`impl` block][6], which turns its methods into [GraphQL fields][4]:
```rust
# extern crate juniper;
# use juniper::{graphql_object, GraphQLObject};
# use juniper::{GraphQLObject, graphql_object};
#
#[derive(GraphQLObject)]
struct Person {
Expand Down
4 changes: 2 additions & 2 deletions book/src/types/objects/error/field.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ For recoverable errors, [Juniper] works well with the [built-in `Result` type][1
```rust
# extern crate juniper;
# use std::{fs::File, io::Read, path::PathBuf, str};
# use juniper::{graphql_object, FieldResult};
# use juniper::{FieldResult, graphql_object};
#
struct Example {
filename: PathBuf,
Expand Down Expand Up @@ -108,7 +108,7 @@ If the `File::open()` above results in a `std::io::ErrorKind::PermissionDenied`,
Sometimes it's desirable to return additional structured error information to clients. This can be accomplished by implementing the [`IntoFieldError` trait][23]:
```rust
# #[macro_use] extern crate juniper;
# use juniper::{graphql_object, FieldError, IntoFieldError, ScalarValue};
# use juniper::{FieldError, IntoFieldError, ScalarValue, graphql_object};
#
enum CustomError {
WhateverNotSet,
Expand Down
8 changes: 4 additions & 4 deletions book/src/types/objects/error/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Critical errors are returned from resolvers as [field errors][1] (from the [prev
In this example, basic input validation is implemented with [GraphQL types][7]. [Strings][5] are used to identify the problematic [field][6] name. Errors for a particular [field][6] are also returned as a [string][5].
```rust
# extern crate juniper;
# use juniper::{graphql_object, GraphQLObject, GraphQLUnion};
# use juniper::{GraphQLObject, GraphQLUnion, graphql_object};
#
#[derive(GraphQLObject)]
pub struct Item {
Expand Down Expand Up @@ -108,7 +108,7 @@ Instead of using [strings][5] to propagate errors, it is possible to use [GraphQ
For each fallible [input argument][4] we create a [field][6] in a [GraphQL object][10]. The [field][6] is set if the validation for that particular [argument][4] fails.
```rust
# extern crate juniper;
# use juniper::{graphql_object, GraphQLObject, GraphQLUnion};
# use juniper::{GraphQLObject, GraphQLUnion, graphql_object};
#
#[derive(GraphQLObject)]
pub struct Item {
Expand Down Expand Up @@ -184,7 +184,7 @@ Our examples so far have only included non-critical errors. Providing errors ins
In the following example, a theoretical database could fail and would generate errors. Since it is not common for a database to fail, the corresponding error is returned as a [critical error][1]:
```rust
# extern crate juniper;
# use juniper::{graphql_object, graphql_value, FieldError, GraphQLObject, GraphQLUnion, ScalarValue};
# use juniper::{FieldError, GraphQLObject, GraphQLUnion, ScalarValue, graphql_object, graphql_value};
#
#[derive(GraphQLObject)]
pub struct Item {
Expand Down Expand Up @@ -261,7 +261,7 @@ Up until now, we've only looked at mapping [structs][20] to [GraphQL objects][10
Using `Result`-like [enums][1] can be a useful way of reporting validation errors from a mutation:
```rust
# extern crate juniper;
# use juniper::{graphql_object, GraphQLObject};
# use juniper::{GraphQLObject, graphql_object};
#
#[derive(GraphQLObject)]
struct User {
Expand Down
2 changes: 1 addition & 1 deletion book/src/types/objects/generics.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This poses a restriction on what we can expose in [GraphQL] from [Rust]: no gene
Let's make a slightly more compact but generic implementation of [the last schema error example](error/schema.md#example-non-struct-objects):
```rust
# extern crate juniper;
# use juniper::{graphql_object, GraphQLObject};
# use juniper::{GraphQLObject, graphql_object};
#
#[derive(GraphQLObject)]
struct User {
Expand Down
4 changes: 2 additions & 2 deletions book/src/types/scalars.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ We can create [custom scalars][2] for other primitive values, but they are still
Quite often, we want to create a [custom GraphQL scalar][2] type by just wrapping an existing one, inheriting all its behavior. In [Rust], this is often called as ["newtype pattern"][3]. This may be achieved by providing a `#[graphql(transparent)]` attribute to the definition:
```rust
# extern crate juniper;
# use juniper::{graphql_scalar, GraphQLScalar};
# use juniper::{GraphQLScalar, graphql_scalar};
#
#[derive(GraphQLScalar)]
#[graphql(transparent)]
Expand Down Expand Up @@ -352,7 +352,7 @@ For implementing [custom scalars][2] on foreign types there is [`#[graphql_scala
# }
#
# use juniper::DefaultScalarValue as CustomScalarValue;
use juniper::{graphql_scalar, InputValue, ScalarValue, Value};
use juniper::{InputValue, ScalarValue, Value, graphql_scalar};

#[graphql_scalar(
with = date_scalar,
Expand Down
3 changes: 2 additions & 1 deletion juniper/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ All user visible changes to `juniper` crate will be documented in this file. Thi
### BC Breaks

- Upgraded [`chrono-tz` crate] integration to [0.10 version](https://github.com/chronotope/chrono-tz/releases/tag/v0.10.0). ([#1252], [#1284])
- Bumped up [MSRV] to 1.75. ([#1272])
- Bumped up [MSRV] to 1.85. ([#1272], [todo])
- Corrected compliance with newer [graphql-scalars.dev] specs: ([#1275], [#1277])
- Switched `LocalDateTime` scalars to `yyyy-MM-ddTHH:mm:ss` format in types:
- `chrono::NaiveDateTime`.
Expand Down Expand Up @@ -59,6 +59,7 @@ All user visible changes to `juniper` crate will be documented in this file. Thi
[#1284]: /../../pull/1284
[#1300]: /../../pull/1300
[#1311]: /../../pull/1311
[todo]: /../../commit/todo



Expand Down
4 changes: 2 additions & 2 deletions juniper/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "juniper"
version = "0.16.1"
edition = "2021"
rust-version = "1.75"
edition = "2024"
rust-version = "1.85"
description = "GraphQL server library."
license = "BSD-2-Clause"
authors = [
Expand Down
4 changes: 2 additions & 2 deletions juniper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Juniper (GraphQL server library for Rust)

[![Crates.io](https://img.shields.io/crates/v/juniper.svg?maxAge=2592000)](https://crates.io/crates/juniper)
[![Documentation](https://docs.rs/juniper/badge.svg)](https://docs.rs/juniper)
[![CI](https://github.com/graphql-rust/juniper/workflows/CI/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster)
[![Rust 1.75+](https://img.shields.io/badge/rustc-1.75+-lightgray.svg "Rust 1.75+")](https://blog.rust-lang.org/2023/12/28/Rust-1.75.0.html)
[![CI](https://github.com/graphql-rust/juniper/actions/workflows/ci.yml/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster)
[![Rust 1.85+](https://img.shields.io/badge/rustc-1.85+-lightgray.svg "Rust 1.85+")](https://blog.rust-lang.org/2025/02/20/Rust-1.85.0.html)

- [Juniper Book] ([current][Juniper Book] | [edge][Juniper Book edge])
- [Changelog](https://github.com/graphql-rust/juniper/blob/juniper-v0.16.1/juniper/CHANGELOG.md)
Expand Down
5 changes: 2 additions & 3 deletions juniper/benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use bencher::{benchmark_group, benchmark_main, Bencher};
use bencher::{Bencher, benchmark_group, benchmark_main};
use juniper::{
execute_sync, graphql_vars,
DefaultScalarValue, EmptyMutation, EmptySubscription, RootNode, execute_sync, graphql_vars,
tests::fixtures::starwars::schema::{Database, Query},
DefaultScalarValue, EmptyMutation, EmptySubscription, RootNode,
};

fn query_type_name(b: &mut Bencher) {
Expand Down
4 changes: 3 additions & 1 deletion juniper/src/executor/look_ahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,9 @@ impl<'a, S> LookAheadSelection<'a, S> {
///
/// [arguments]: https://spec.graphql.org/October2021#sec-Language.Arguments
/// [selection]: https://spec.graphql.org/October2021#sec-Selection-Sets
pub fn arguments(&self) -> impl DoubleEndedIterator<Item = LookAheadArgument<'a, S>> {
pub fn arguments(
&self,
) -> impl DoubleEndedIterator<Item = LookAheadArgument<'a, S>> + use<'a, S> {
let opt_arguments = match self.source {
SelectionSource::Field(f) => f.arguments.as_ref(),
_ => None,
Expand Down
4 changes: 2 additions & 2 deletions juniper/src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use fnv::FnvHashMap;
use futures::Stream;

use crate::{
GraphQLError,
ast::{
Definition, Document, Fragment, FromInputValue, InputValue, Operation, OperationType,
Selection, ToInputValue, Type,
Expand All @@ -32,7 +33,6 @@ use crate::{
subscriptions::{GraphQLSubscriptionType, GraphQLSubscriptionValue},
},
value::{DefaultScalarValue, ParseScalarValue, ScalarValue, Value},
GraphQLError,
};

pub use self::{
Expand Down Expand Up @@ -701,7 +701,7 @@ where
// Search the parent's fields to find this field within the selection set.
p.iter().find_map(|x| {
match x {
Selection::Field(ref field) => {
Selection::Field(field) => {
let field = &field.item;
// TODO: support excludes.
let name = field.name.item;
Expand Down
2 changes: 1 addition & 1 deletion juniper/src/executor/owned_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use std::{
};

use crate::{
ExecutionError, Executor, Selection, Variables,
ast::Fragment,
executor::FieldPath,
parser::SourcePosition,
schema::model::{SchemaType, TypeType},
ExecutionError, Executor, Selection, Variables,
};

/// [`Executor`] owning all its variables. Can be used after [`Executor`] was
Expand Down
4 changes: 2 additions & 2 deletions juniper/src/executor_tests/async_await/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
graphql_object, graphql_value, graphql_vars, EmptyMutation, EmptySubscription, GraphQLEnum,
RootNode, Value,
EmptyMutation, EmptySubscription, GraphQLEnum, RootNode, Value, graphql_object, graphql_value,
graphql_vars,
};

#[derive(GraphQLEnum)]
Expand Down
4 changes: 2 additions & 2 deletions juniper/src/executor_tests/enums.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::{
GraphQLEnum,
GraphQLError::ValidationError,
executor::Variables,
graphql_value, graphql_vars,
parser::SourcePosition,
schema::model::RootNode,
types::scalars::{EmptyMutation, EmptySubscription},
validation::RuleError,
value::{DefaultScalarValue, Object},
GraphQLEnum,
GraphQLError::ValidationError,
};

#[derive(GraphQLEnum, Debug)]
Expand Down
Loading

0 comments on commit 1b1fc61

Please sign in to comment.