Skip to content

Commit 8453620

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents b7eb36a + c42c71b commit 8453620

File tree

139 files changed

+4401
-1712
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+4401
-1712
lines changed

.travis.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
[workspace]
22
# Order is important as this is the order the crates will be released.
33
members = [
4+
"juniper_benchmarks",
45
"juniper_codegen",
56
"juniper",
67
"integration_tests/juniper_tests",
8+
"integration_tests/async_await",
79
"juniper_hyper",
810
"juniper_iron",
911
"juniper_rocket",
10-
"juniper_warp",
1112
]
1213
exclude = [
1314
"docs/book/tests",
15+
# TODO enable warp
16+
"juniper_warp",
17+
"examples/warp_async",
18+
# TODO enable async tests
19+
"juniper_rocket_async",
1420
]

Makefile.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# https://github.com/sagiegurari/cargo-make#automatically-extend-workspace-makefile
22
[env]
33
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
4+
CARGO_MAKE_CARGO_ALL_FEATURES = ""
45

56
#
67
# Run `RELEASE_LEVEL=(patch|major|minor) cargo make release` to push a new release of every crate.
@@ -86,3 +87,12 @@ condition = { env_set = [ "RELEASE_LEVEL" ] }
8687
description = "Run `cargo-release` for every crate, but only make changes locally"
8788
command = "cargo-release"
8889
args = ["release", "--config", "${CARGO_MAKE_WORKING_DIRECTORY}/../_build/release.toml", "--no-confirm", "--skip-publish", "--skip-push", "--skip-tag", "${RELEASE_LEVEL}"]
90+
91+
[tasks.test-verbose]
92+
dependencies = ["test-async-verbose"]
93+
94+
[tasks.test-async-verbose]
95+
description = "Runs cargo test with async feature"
96+
category = "Test"
97+
command = "cargo"
98+
args = ["test", "--verbose", "--features", "async", "@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )"]

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
> GraphQL server library for Rust
44
5-
[![Build Status](https://travis-ci.org/graphql-rust/juniper.svg?branch=master)](https://travis-ci.org/graphql-rust/juniper)
65
[![Build Status](https://dev.azure.com/graphql-rust/GraphQL%20Rust/_apis/build/status/graphql-rust.juniper)](https://dev.azure.com/graphql-rust/GraphQL%20Rust/_build/latest?definitionId=1)
76
[![codecov](https://codecov.io/gh/graphql-rust/juniper/branch/master/graph/badge.svg)](https://codecov.io/gh/graphql-rust/juniper)
87
[![Crates.io](https://img.shields.io/crates/v/juniper.svg?maxAge=2592000)](https://crates.io/crates/juniper)

_build/azure-pipelines-template.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ jobs:
2121
- script: |
2222
export CARGO_HOME="$HOME/.cargo"
2323
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN
24-
source /usr/local/cargo/env;
2524
echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
2625
displayName: Install rust
2726
- ${{ if eq(parameters.name, 'Windows') }}:
@@ -61,7 +60,6 @@ jobs:
6160
# Not Windows.
6261
- script: |
6362
export PATH="$PATH:$HOME/.cargo/bin";
64-
source /usr/local/cargo/env;
6563
cargo make workspace-ci-flow --no-workspace
6664
env: { CARGO_MAKE_RUN_CODECOV: true }
6765
displayName: Build and run tests

docs/book/content/advanced/introspection.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl juniper::Context for Context {}
4444

4545
struct Query;
4646

47-
#[juniper::object(
47+
#[juniper::graphql_object(
4848
Context = Context,
4949
)]
5050
impl Query {

docs/book/content/advanced/non_struct_objects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ enum SignUpResult {
2323
Error(Vec<ValidationError>),
2424
}
2525

26-
#[juniper::object]
26+
#[juniper::graphql_object]
2727
impl SignUpResult {
2828
fn user(&self) -> Option<&User> {
2929
match *self {

docs/book/content/advanced/objects_and_generics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct ValidationError {
2525
# #[allow(dead_code)]
2626
struct MutationResult<T>(Result<T, Vec<ValidationError>>);
2727

28-
#[juniper::object(
28+
#[juniper::graphql_object(
2929
name = "UserResult",
3030
)]
3131
impl MutationResult<User> {
@@ -38,7 +38,7 @@ impl MutationResult<User> {
3838
}
3939
}
4040

41-
#[juniper::object(
41+
#[juniper::graphql_object(
4242
name = "ForumPostResult",
4343
)]
4444
impl MutationResult<ForumPost> {

docs/book/content/quickstart.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This page will give you a short introduction to the concepts in Juniper.
88

99
```toml
1010
[dependencies]
11-
juniper = "0.11"
11+
juniper = "0.14.2"
1212
```
1313

1414
## Schema example
@@ -74,7 +74,7 @@ impl juniper::Context for Context {}
7474

7575
struct Query;
7676

77-
#[juniper::object(
77+
#[juniper::graphql_object(
7878
// Here we specify the context type for the object.
7979
// We need to do this in every type that
8080
// needs access to the context.
@@ -105,7 +105,7 @@ impl Query {
105105

106106
struct Mutation;
107107

108-
#[juniper::object(
108+
#[juniper::graphql_object(
109109
Context = Context,
110110
)]
111111
impl Mutation {
@@ -156,7 +156,7 @@ impl juniper::Context for Ctx {}
156156

157157
struct Query;
158158

159-
#[juniper::object(
159+
#[juniper::graphql_object(
160160
Context = Ctx,
161161
)]
162162
impl Query {

docs/book/content/schema/schemas_and_mutations.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ object in Juniper, most commonly using the `object` proc macro:
2727
# #[derive(juniper::GraphQLObject)] struct User { name: String }
2828
struct Root;
2929

30-
#[juniper::object]
30+
#[juniper::graphql_object]
3131
impl Root {
3232
fn userWithUsername(username: String) -> FieldResult<Option<User>> {
3333
// Look up user in database...
@@ -48,7 +48,7 @@ usually performs some mutating side-effect, such as updating a database.
4848
# #[derive(juniper::GraphQLObject)] struct User { name: String }
4949
struct Mutations;
5050

51-
#[juniper::object]
51+
#[juniper::graphql_object]
5252
impl Mutations {
5353
fn signUpUser(name: String, email: String) -> FieldResult<User> {
5454
// Validate inputs and save user in database...

docs/book/content/servers/iron.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn context_factory(_: &mut Request) -> IronResult<()> {
4747
4848
struct Root;
4949
50-
#[juniper::object]
50+
#[juniper::graphql_object]
5151
impl Root {
5252
fn foo() -> String {
5353
"Bar".to_owned()
@@ -99,7 +99,7 @@ fn context_factory(req: &mut Request) -> IronResult<Context> {
9999
100100
struct Root;
101101
102-
#[juniper::object(
102+
#[juniper::graphql_object(
103103
Context = Context,
104104
)]
105105
impl Root {

docs/book/content/types/input_objects.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct Coordinate {
1414
struct Root;
1515
# #[derive(juniper::GraphQLObject)] struct User { name: String }
1616

17-
#[juniper::object]
17+
#[juniper::graphql_object]
1818
impl Root {
1919
fn users_at_location(coordinate: Coordinate, radius: f64) -> Vec<User> {
2020
// Send coordinate to database
@@ -45,7 +45,7 @@ struct WorldCoordinate {
4545
struct Root;
4646
# #[derive(juniper::GraphQLObject)] struct User { name: String }
4747

48-
#[juniper::object]
48+
#[juniper::graphql_object]
4949
impl Root {
5050
fn users_at_location(coordinate: WorldCoordinate, radius: f64) -> Vec<User> {
5151
// Send coordinate to database

docs/book/content/types/interfaces.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl Character for Droid {
4949
fn as_droid(&self) -> Option<&Droid> { Some(&self) }
5050
}
5151

52-
juniper::graphql_interface!(<'a> &'a Character: () as "Character" where Scalar = <S> |&self| {
52+
juniper::graphql_interface!(<'a> &'a dyn Character: () as "Character" where Scalar = <S> |&self| {
5353
field id() -> &str { self.id() }
5454

5555
instance_resolvers: |_| {
@@ -111,7 +111,7 @@ impl Character for Droid {
111111
fn id(&self) -> &str { self.id.as_str() }
112112
}
113113

114-
juniper::graphql_interface!(<'a> &'a Character: Database as "Character" where Scalar = <S> |&self| {
114+
juniper::graphql_interface!(<'a> &'a dyn Character: Database as "Character" where Scalar = <S> |&self| {
115115
field id() -> &str { self.id() }
116116

117117
instance_resolvers: |&context| {

docs/book/content/types/objects/complex_fields.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct Person {
1414
age: i32,
1515
}
1616

17-
#[juniper::object]
17+
#[juniper::graphql_object]
1818
impl Person {
1919
fn name(&self) -> &str {
2020
self.name.as_str()
@@ -25,6 +25,14 @@ impl Person {
2525
}
2626
}
2727

28+
// Note that this syntax generates an implementation of the GraphQLType trait,
29+
// the base impl of your struct can still be written like usual:
30+
impl Person {
31+
pub fn hidden_from_graphql(&self) {
32+
// [...]
33+
}
34+
}
35+
2836
# fn main() { }
2937
```
3038

@@ -43,7 +51,7 @@ struct House {
4351
inhabitants: Vec<Person>,
4452
}
4553

46-
#[juniper::object]
54+
#[juniper::graphql_object]
4755
impl House {
4856
// Creates the field inhabitantWithName(name), returning a nullable person
4957
fn inhabitant_with_name(&self, name: String) -> Option<&Person> {
@@ -70,7 +78,7 @@ struct Person {
7078
}
7179

7280
/// Doc comments are used as descriptions for GraphQL.
73-
#[juniper::object(
81+
#[juniper::graphql_object(
7482
// With this attribtue you can change the public GraphQL name of the type.
7583
name = "PersonObject",
7684
// You can also specify a description here, which will overwrite
@@ -125,7 +133,7 @@ This will become better once the [Rust RFC 2565](https://github.com/rust-lang/ru
125133

126134
struct Person {}
127135

128-
#[juniper::object]
136+
#[juniper::graphql_object]
129137
impl Person {
130138
#[graphql(
131139
arguments(

docs/book/content/types/objects/error_handling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct Example {
2525
filename: PathBuf,
2626
}
2727

28-
#[juniper::object]
28+
#[juniper::graphql_object]
2929
impl Example {
3030
fn contents() -> FieldResult<String> {
3131
let mut file = File::open(&self.filename)?;
@@ -143,7 +143,7 @@ struct Example {
143143
whatever: Option<bool>,
144144
}
145145

146-
#[juniper::object]
146+
#[juniper::graphql_object]
147147
impl Example {
148148
fn whatever() -> Result<bool, CustomError> {
149149
if let Some(value) = self.whatever {

docs/book/content/types/objects/using_contexts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct User {
5757

5858

5959
// Assign Database as the context type for User
60-
#[juniper::object(
60+
#[juniper::graphql_object(
6161
Context = Database,
6262
)]
6363
impl User {

docs/book/content/types/scalars.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ juniper::graphql_scalar!(Date where Scalar = <S> {
121121

122122
// Define how to parse a primitive type into your custom scalar.
123123
from_input_value(v: &InputValue) -> Option<Date> {
124-
v.as_scalar_value::<String>()
125-
.and_then(|s| s.parse().ok())
124+
v.as_scalar_value()
125+
.and_then(|v| v.as_str())
126+
.and_then(|s| s.parse().ok())
126127
}
127128

128129
// Define how to parse a string value.

0 commit comments

Comments
 (0)