Skip to content

Commit de12e0e

Browse files
committed
Formatting...
1 parent 3cc142b commit de12e0e

File tree

6 files changed

+40
-48
lines changed

6 files changed

+40
-48
lines changed

juniper/src/lib.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,14 @@ extern crate uuid;
109109
// This allows users to just depend on juniper and get the derive
110110
// functionality automatically.
111111
pub use juniper_codegen::{
112-
GraphQLEnum,
113-
GraphQLInputObject,
114-
GraphQLObject,
115-
GraphQLScalarValue,
116-
ScalarValue,
117-
impl_object,
112+
impl_object, GraphQLEnum, GraphQLInputObject, GraphQLObject, GraphQLScalarValue, ScalarValue,
118113
};
119-
// Internal macros are not exported,
114+
// Internal macros are not exported,
120115
// but declared at the root to make them easier to use.
121116
#[allow(unused_imports)]
122117
use juniper_codegen::{
118+
impl_object_internal, GraphQLEnumInternal, GraphQLInputObjectInternal,
123119
GraphQLScalarValueInternal,
124-
GraphQLEnumInternal,
125-
GraphQLInputObjectInternal,
126-
impl_object_internal,
127120
};
128121

129122
#[macro_use]

juniper/src/macros/object.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
## DEPRECATION WARNING
33
4-
The `graphql_object!` macro is deprecated and will be removed soon.
4+
The `graphql_object!` macro is deprecated and will be removed soon.
55
Use the new[impl_object](https://docs.rs/juniper/latest/juniper/macro.impl_object.html) macro instead.
66
77
Expose GraphQL objects

juniper/src/schema/schema.rs

+13-17
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,13 @@ where
146146
fn fields(&self, include_deprecated: bool) -> Option<Vec<&Field<S>>> {
147147
match *self {
148148
TypeType::Concrete(&MetaType::Interface(InterfaceMeta { ref fields, .. }))
149-
| TypeType::Concrete(&MetaType::Object(ObjectMeta { ref fields, .. })) => {
150-
Some(
151-
fields
152-
.iter()
153-
.filter(|f| include_deprecated || !f.deprecation_status.is_deprecated())
154-
.filter(|f| !f.name.starts_with("__"))
155-
.collect(),
156-
)
157-
}
149+
| TypeType::Concrete(&MetaType::Object(ObjectMeta { ref fields, .. })) => Some(
150+
fields
151+
.iter()
152+
.filter(|f| include_deprecated || !f.deprecation_status.is_deprecated())
153+
.filter(|f| !f.name.starts_with("__"))
154+
.collect(),
155+
),
158156
_ => None,
159157
}
160158
}
@@ -233,14 +231,12 @@ where
233231
#[graphql(arguments(include_deprecated(default = false)))]
234232
fn enum_values(&self, include_deprecated: bool) -> Option<Vec<&EnumValue>> {
235233
match *self {
236-
TypeType::Concrete(&MetaType::Enum(EnumMeta { ref values, .. })) => {
237-
Some(
238-
values
239-
.iter()
240-
.filter(|f| include_deprecated || !f.deprecation_status.is_deprecated())
241-
.collect(),
242-
)
243-
}
234+
TypeType::Concrete(&MetaType::Enum(EnumMeta { ref values, .. })) => Some(
235+
values
236+
.iter()
237+
.filter(|f| include_deprecated || !f.deprecation_status.is_deprecated())
238+
.collect(),
239+
),
244240
_ => None,
245241
}
246242
}

juniper_codegen/src/impl_object.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub fn build_impl_object(args: TokenStream, body: TokenStream, is_internal: bool
148148
// Check for executor arguments.
149149
if util::type_is_identifier_ref(&captured.ty, "Executor") {
150150
resolve_parts.push(quote!(let #arg_ident = executor;));
151-
}
151+
}
152152
// Make sure executor is specified as a reference.
153153
else if util::type_is_identifier(&captured.ty, "Executor") {
154154
panic!("Invalid executor argument: to access the Executor, you need to specify the type as a reference.\nDid you mean &Executor?");
@@ -160,16 +160,19 @@ pub fn build_impl_object(args: TokenStream, body: TokenStream, is_internal: bool
160160
.unwrap_or(false)
161161
{
162162
resolve_parts.push(quote!( let #arg_ident = executor.context(); ));
163-
}
163+
}
164164
// Make sure the user does not specify the Context
165165
// without a reference. (&Context)
166-
else if context_type.clone().map(|ctx| ctx == &captured.ty).unwrap_or(false) {
166+
else if context_type
167+
.clone()
168+
.map(|ctx| ctx == &captured.ty)
169+
.unwrap_or(false)
170+
{
167171
panic!(
168172
"Invalid context argument: to access the context, you need to specify the type as a reference.\nDid you mean &{}?",
169173
quote!(captured.ty),
170174
);
171-
}
172-
else {
175+
} else {
173176
let ty = &captured.ty;
174177
// TODO: respect graphql attribute overwrite.
175178
let final_name = util::to_camel_case(&arg_name);

juniper_codegen/src/lib.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@ pub fn derive_scalar_value_internal(input: TokenStream) -> TokenStream {
7979
The `impl_object` proc macro is the primary way of defining GraphQL resolvers
8080
that can not be implemented with the GraphQLObject derive.
8181
82-
It enables you to write GraphQL field resolvers for a type by declaring a
82+
It enables you to write GraphQL field resolvers for a type by declaring a
8383
regular Rust `impl` block. Under the hood, the procedural macro implements
8484
the GraphQLType trait.
8585
86-
`impl_object` comes with many features that allow customization of
86+
`impl_object` comes with many features that allow customization of
8787
your fields, all of which are detailed below.
8888
8989
### Getting Started
9090
91-
This simple example will show you the most basic use of `impl_object`.
91+
This simple example will show you the most basic use of `impl_object`.
9292
More advanced use cases are introduced step by step.
9393
9494
```
@@ -105,17 +105,17 @@ impl Query {
105105
106106
107107
// This defines a simple, static field which does not require any context.
108-
// You can return any value that implements the `GraphQLType` trait.
108+
// You can return any value that implements the `GraphQLType` trait.
109109
// This trait is implemented for:
110110
// - basic scalar types like bool, &str, String, i32, f64
111111
// - GraphQL compatible wrappers like Option<_>, Vec<_>.
112112
// - types which use the `#derive[juniper::GraphQLObject]`
113113
// - `impl_object` structs.
114-
//
115-
// An important note regarding naming:
114+
//
115+
// An important note regarding naming:
116116
// By default, field names will be converted to camel case.
117117
// For your GraphQL queries, the field will be available as `apiVersion`.
118-
//
118+
//
119119
// You can also manually customize the field name if required. (See below)
120120
fn api_version() -> &'static str {
121121
"0.1"
@@ -169,7 +169,7 @@ You can specify a context that will be available across
169169
all your resolvers during query execution.
170170
171171
The Context can be injected into your resolvers by just
172-
specifying an argument with the same type as the context
172+
specifying an argument with the same type as the context
173173
(but as a reference).
174174
175175
```
@@ -198,11 +198,11 @@ impl Query {
198198
context.db.user(id)
199199
}
200200
201-
// You can also gain access to the executor, which
201+
// You can also gain access to the executor, which
202202
// allows you to do look aheads.
203203
fn with_executor(executor: &Executor) -> bool {
204204
let info = executor.look_ahead();
205-
// ...
205+
// ...
206206
true
207207
}
208208
}

juniper_codegen/src/util.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ pub struct GraphQLTypeDefiniton {
611611
// This flag signifies if the type generics need to be
612612
// included manually.
613613
pub include_type_generics: bool,
614-
// This flag indicates if the generated code should always be
614+
// This flag indicates if the generated code should always be
615615
// generic over the ScalarValue.
616616
// If false, the scalar is only generic if a generic parameter
617617
// is specified manually.
@@ -744,7 +744,7 @@ impl GraphQLTypeDefiniton {
744744
// A custom scalar type was specified.
745745
// Therefore, we always insert a where clause that marks the scalar as
746746
// compatible with ScalarValueRef.
747-
// This is done to prevent the user from having to specify this
747+
// This is done to prevent the user from having to specify this
748748
// manually.
749749
let where_clause = generics.where_clause.get_or_insert(parse_quote!(where));
750750
where_clause.predicates.push(
@@ -764,9 +764,9 @@ impl GraphQLTypeDefiniton {
764764
// Insert a where clause that marks the scalar as
765765
// compatible with ScalarValueRef.
766766
// Same as in branch above.
767-
where_clause.predicates.push(
768-
parse_quote!(for<'__b> &'__b __S: #juniper_crate_name::ScalarRefValue<'__b>),
769-
);
767+
where_clause
768+
.predicates
769+
.push(parse_quote!(for<'__b> &'__b __S: #juniper_crate_name::ScalarRefValue<'__b>));
770770
}
771771

772772
let type_generics_tokens = if self.include_type_generics {

0 commit comments

Comments
 (0)