Skip to content

Commit 29025e6

Browse files
committed
Rename impl_object to object.
1 parent 520cac2 commit 29025e6

39 files changed

+103
-104
lines changed

docs/book/content/advanced/introspection.md

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

4545
struct Query;
4646

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

docs/book/content/advanced/non_struct_objects.md

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

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

docs/book/content/advanced/objects_and_generics.md

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

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

docs/book/content/quickstart.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ naturally map to GraphQL features, such as `Option<T>`, `Vec<T>`, `Box<T>`,
2020

2121
For more advanced mappings, Juniper provides multiple macros to map your Rust
2222
types to a GraphQL schema. The most important one is the
23-
[impl_object][jp_impl_object] procedural macro that is used for declaring an object with
23+
[object][jp_object] procedural macro that is used for declaring an object with
2424
resolvers, which you will use for the `Query` and `Mutation` roots.
2525

2626
```rust
@@ -60,7 +60,7 @@ struct NewHuman {
6060
}
6161

6262
// Now, we create our root Query and Mutation types with resolvers by using the
63-
// impl_object macro.
63+
// object macro.
6464
// Objects can have contexts that allow accessing shared state like a database
6565
// pool.
6666

@@ -74,7 +74,7 @@ impl juniper::Context for Context {}
7474

7575
struct Query;
7676

77-
#[juniper::impl_object(
77+
#[juniper::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::impl_object(
108+
#[juniper::object(
109109
Context = Context,
110110
)]
111111
impl Mutation {
@@ -156,7 +156,7 @@ impl juniper::Context for Ctx {}
156156

157157
struct Query;
158158

159-
#[juniper::impl_object(
159+
#[juniper::object(
160160
Context = Ctx,
161161
)]
162162
impl Query {
@@ -198,4 +198,4 @@ fn main() {
198198
[rocket]: servers/rocket.md
199199
[iron]: servers/iron.md
200200
[tutorial]: ./tutorial.html
201-
[jp_obj_macro]: https://docs.rs/juniper/latest/juniper/macro.impl_object.html
201+
[jp_obj_macro]: https://docs.rs/juniper/latest/juniper/macro.object.html

docs/book/content/schema/schemas_and_mutations.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ object somewhere but never references it, it will not be exposed in a schema.
2020
## The query root
2121

2222
The query root is just a GraphQL object. You define it like any other GraphQL
23-
object in Juniper, most commonly using the `impl_object` proc macro:
23+
object in Juniper, most commonly using the `object` proc macro:
2424

2525
```rust
2626
# use juniper::FieldResult;
2727
# #[derive(juniper::GraphQLObject)] struct User { name: String }
2828
struct Root;
2929

30-
#[juniper::impl_object]
30+
#[juniper::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::impl_object]
51+
#[juniper::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

+2-2
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::impl_object]
50+
#[juniper::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::impl_object(
102+
#[juniper::object(
103103
Context = Context,
104104
)]
105105
impl Root {

docs/book/content/types/input_objects.md

+2-2
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::impl_object]
17+
#[juniper::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::impl_object]
48+
#[juniper::object]
4949
impl Root {
5050
fn users_at_location(coordinate: WorldCoordinate, radius: f64) -> Vec<User> {
5151
// Send coordinate to database

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
If you've got a struct that can't be mapped directly to GraphQL, that contains
44
computed fields or circular structures, you have to use a more powerful tool:
5-
the `impl_object` procedural macro. This macro lets you define GraphQL object
5+
the `object` procedural macro. This macro lets you define GraphQL object
66
fields in a Rust `impl` block for a type. Continuing with the
77
example from the last chapter, this is how you would define `Person` using the
88
macro:
@@ -14,7 +14,7 @@ struct Person {
1414
age: i32,
1515
}
1616

17-
#[juniper::impl_object]
17+
#[juniper::object]
1818
impl Person {
1919
fn name(&self) -> &str {
2020
self.name.as_str()
@@ -43,7 +43,7 @@ struct House {
4343
inhabitants: Vec<Person>,
4444
}
4545

46-
#[juniper::impl_object]
46+
#[juniper::object]
4747
impl House {
4848
// Creates the field inhabitantWithName(name), returning a nullable person
4949
fn inhabitant_with_name(&self, name: String) -> Option<&Person> {
@@ -70,7 +70,7 @@ struct Person {
7070
website_url: String,
7171
}
7272

73-
#[juniper::impl_object(
73+
#[juniper::object(
7474
// With this attribtue you can change the public GraphQL name of the type.
7575
name = "PersonObject",
7676
)]
@@ -96,4 +96,4 @@ GraphQL fields expose more features than Rust's standard method syntax gives us:
9696
* Per-argument descriptions
9797

9898
These, and more features, are described more thorougly in [the reference
99-
documentation](https://docs.rs/juniper/latest/juniper/macro.impl_object.html).
99+
documentation](https://docs.rs/juniper/latest/juniper/macro.object.html).

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

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

28-
#[juniper::impl_object]
28+
#[juniper::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::impl_object]
146+
#[juniper::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

+1-1
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::impl_object(
60+
#[juniper::object(
6161
Context = Database,
6262
)]
6363
impl User {

integration_tests/juniper_tests/src/codegen/derive_object.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct WithCustomContext {
8080
a: bool,
8181
}
8282

83-
#[juniper::impl_object]
83+
#[juniper::object]
8484
impl Query {
8585
fn obj() -> Obj {
8686
Obj {

integration_tests/juniper_tests/src/custom_scalar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ juniper::graphql_scalar!(i64 as "Long" where Scalar = MyScalarValue {
151151

152152
struct TestType;
153153

154-
#[juniper::impl_object(
154+
#[juniper::object(
155155
Scalar = MyScalarValue
156156
)]
157157
impl TestType {

juniper/CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# master
22

3-
### impl_object macro
3+
### object macro
44

55
The `graphql_object!` macro is deprecated and will be removed in the future.
6-
It is replaced by the new [impl_object](https://docs.rs/juniper/latest/juniper/macro.impl_object.html) procedural macro.
6+
It is replaced by the new [object](https://docs.rs/juniper/latest/juniper/macro.object.html) procedural macro.
77

88
[#333](https://github.com/graphql-rust/juniper/pull/333)
99

juniper/src/executor_tests/directives.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::value::{DefaultScalarValue, Object, Value};
55

66
struct TestType;
77

8-
#[crate::impl_object_internal]
8+
#[crate::object_internal]
99
impl TestType {
1010
fn a() -> &str {
1111
"a"

juniper/src/executor_tests/enums.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ enum Color {
1717
}
1818
struct TestType;
1919

20-
#[crate::impl_object_internal]
20+
#[crate::object_internal]
2121
impl TestType {
2222
fn to_string(color: Color) -> String {
2323
format!("Color::{:?}", color)

juniper/src/executor_tests/executor.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mod field_execution {
77
struct DataType;
88
struct DeepDataType;
99

10-
#[crate::impl_object_internal]
10+
#[crate::object_internal]
1111
impl DataType {
1212
fn a() -> &str {
1313
"Apple"
@@ -37,7 +37,7 @@ mod field_execution {
3737
}
3838
}
3939

40-
#[crate::impl_object_internal]
40+
#[crate::object_internal]
4141
impl DeepDataType {
4242
fn a() -> &str {
4343
"Already Been Done"
@@ -162,7 +162,7 @@ mod merge_parallel_fragments {
162162

163163
struct Type;
164164

165-
#[crate::impl_object_internal]
165+
#[crate::object_internal]
166166
impl Type {
167167
fn a() -> &str {
168168
"Apple"
@@ -246,7 +246,7 @@ mod merge_parallel_inline_fragments {
246246
struct Type;
247247
struct Other;
248248

249-
#[crate::impl_object_internal]
249+
#[crate::object_internal]
250250
impl Type {
251251
fn a() -> &str {
252252
"Apple"
@@ -265,7 +265,7 @@ mod merge_parallel_inline_fragments {
265265
}
266266
}
267267

268-
#[crate::impl_object_internal]
268+
#[crate::object_internal]
269269
impl Other {
270270
fn a() -> &str {
271271
"Apple"
@@ -396,7 +396,7 @@ mod threads_context_correctly {
396396

397397
impl Context for TestContext {}
398398

399-
#[crate::impl_object_internal(
399+
#[crate::object_internal(
400400
Context = TestContext,
401401
)]
402402
impl Schema {
@@ -462,7 +462,7 @@ mod dynamic_context_switching {
462462

463463
struct ItemRef;
464464

465-
#[crate::impl_object_internal(Context = OuterContext)]
465+
#[crate::object_internal(Context = OuterContext)]
466466
impl Schema {
467467
fn item_opt(context: &OuterContext, key: i32) -> Option<(&InnerContext, ItemRef)> {
468468
executor.context().items.get(&key).map(|c| (c, ItemRef))
@@ -492,7 +492,7 @@ mod dynamic_context_switching {
492492
}
493493
}
494494

495-
#[crate::impl_object_internal(Context = InnerContext)]
495+
#[crate::object_internal(Context = InnerContext)]
496496
impl ItemRef {
497497
fn value(context: &InnerContext) -> String {
498498
context.value.clone()
@@ -801,7 +801,7 @@ mod propagates_errors_to_nullable_fields {
801801
}
802802
}
803803

804-
#[crate::impl_object_internal]
804+
#[crate::object_internal]
805805
impl Schema {
806806
fn inner() -> Inner {
807807
Inner
@@ -814,7 +814,7 @@ mod propagates_errors_to_nullable_fields {
814814
}
815815
}
816816

817-
#[crate::impl_object_internal]
817+
#[crate::object_internal]
818818
impl Inner {
819819
fn nullable_field() -> Option<Inner> {
820820
Some(Inner)
@@ -1068,7 +1068,7 @@ mod named_operations {
10681068

10691069
struct Schema;
10701070

1071-
#[crate::impl_object_internal]
1071+
#[crate::object_internal]
10721072
impl Schema {
10731073
fn a() -> &str {
10741074
"b"

0 commit comments

Comments
 (0)