Formatting...
This commit is contained in:
parent
3cc142bfbc
commit
de12e0eba5
6 changed files with 40 additions and 48 deletions
|
@ -109,21 +109,14 @@ extern crate uuid;
|
||||||
// This allows users to just depend on juniper and get the derive
|
// This allows users to just depend on juniper and get the derive
|
||||||
// functionality automatically.
|
// functionality automatically.
|
||||||
pub use juniper_codegen::{
|
pub use juniper_codegen::{
|
||||||
GraphQLEnum,
|
impl_object, GraphQLEnum, GraphQLInputObject, GraphQLObject, GraphQLScalarValue, ScalarValue,
|
||||||
GraphQLInputObject,
|
|
||||||
GraphQLObject,
|
|
||||||
GraphQLScalarValue,
|
|
||||||
ScalarValue,
|
|
||||||
impl_object,
|
|
||||||
};
|
};
|
||||||
// Internal macros are not exported,
|
// Internal macros are not exported,
|
||||||
// but declared at the root to make them easier to use.
|
// but declared at the root to make them easier to use.
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use juniper_codegen::{
|
use juniper_codegen::{
|
||||||
|
impl_object_internal, GraphQLEnumInternal, GraphQLInputObjectInternal,
|
||||||
GraphQLScalarValueInternal,
|
GraphQLScalarValueInternal,
|
||||||
GraphQLEnumInternal,
|
|
||||||
GraphQLInputObjectInternal,
|
|
||||||
impl_object_internal,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
@ -146,15 +146,13 @@ where
|
||||||
fn fields(&self, include_deprecated: bool) -> Option<Vec<&Field<S>>> {
|
fn fields(&self, include_deprecated: bool) -> Option<Vec<&Field<S>>> {
|
||||||
match *self {
|
match *self {
|
||||||
TypeType::Concrete(&MetaType::Interface(InterfaceMeta { ref fields, .. }))
|
TypeType::Concrete(&MetaType::Interface(InterfaceMeta { ref fields, .. }))
|
||||||
| TypeType::Concrete(&MetaType::Object(ObjectMeta { ref fields, .. })) => {
|
| TypeType::Concrete(&MetaType::Object(ObjectMeta { ref fields, .. })) => Some(
|
||||||
Some(
|
|
||||||
fields
|
fields
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|f| include_deprecated || !f.deprecation_status.is_deprecated())
|
.filter(|f| include_deprecated || !f.deprecation_status.is_deprecated())
|
||||||
.filter(|f| !f.name.starts_with("__"))
|
.filter(|f| !f.name.starts_with("__"))
|
||||||
.collect(),
|
.collect(),
|
||||||
)
|
),
|
||||||
}
|
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,14 +231,12 @@ where
|
||||||
#[graphql(arguments(include_deprecated(default = false)))]
|
#[graphql(arguments(include_deprecated(default = false)))]
|
||||||
fn enum_values(&self, include_deprecated: bool) -> Option<Vec<&EnumValue>> {
|
fn enum_values(&self, include_deprecated: bool) -> Option<Vec<&EnumValue>> {
|
||||||
match *self {
|
match *self {
|
||||||
TypeType::Concrete(&MetaType::Enum(EnumMeta { ref values, .. })) => {
|
TypeType::Concrete(&MetaType::Enum(EnumMeta { ref values, .. })) => Some(
|
||||||
Some(
|
|
||||||
values
|
values
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|f| include_deprecated || !f.deprecation_status.is_deprecated())
|
.filter(|f| include_deprecated || !f.deprecation_status.is_deprecated())
|
||||||
.collect(),
|
.collect(),
|
||||||
)
|
),
|
||||||
}
|
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,13 +163,16 @@ pub fn build_impl_object(args: TokenStream, body: TokenStream, is_internal: bool
|
||||||
}
|
}
|
||||||
// Make sure the user does not specify the Context
|
// Make sure the user does not specify the Context
|
||||||
// without a reference. (&Context)
|
// without a reference. (&Context)
|
||||||
else if context_type.clone().map(|ctx| ctx == &captured.ty).unwrap_or(false) {
|
else if context_type
|
||||||
|
.clone()
|
||||||
|
.map(|ctx| ctx == &captured.ty)
|
||||||
|
.unwrap_or(false)
|
||||||
|
{
|
||||||
panic!(
|
panic!(
|
||||||
"Invalid context argument: to access the context, you need to specify the type as a reference.\nDid you mean &{}?",
|
"Invalid context argument: to access the context, you need to specify the type as a reference.\nDid you mean &{}?",
|
||||||
quote!(captured.ty),
|
quote!(captured.ty),
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
let ty = &captured.ty;
|
let ty = &captured.ty;
|
||||||
// TODO: respect graphql attribute overwrite.
|
// TODO: respect graphql attribute overwrite.
|
||||||
let final_name = util::to_camel_case(&arg_name);
|
let final_name = util::to_camel_case(&arg_name);
|
||||||
|
|
|
@ -764,9 +764,9 @@ impl GraphQLTypeDefiniton {
|
||||||
// Insert a where clause that marks the scalar as
|
// Insert a where clause that marks the scalar as
|
||||||
// compatible with ScalarValueRef.
|
// compatible with ScalarValueRef.
|
||||||
// Same as in branch above.
|
// Same as in branch above.
|
||||||
where_clause.predicates.push(
|
where_clause
|
||||||
parse_quote!(for<'__b> &'__b __S: #juniper_crate_name::ScalarRefValue<'__b>),
|
.predicates
|
||||||
);
|
.push(parse_quote!(for<'__b> &'__b __S: #juniper_crate_name::ScalarRefValue<'__b>));
|
||||||
}
|
}
|
||||||
|
|
||||||
let type_generics_tokens = if self.include_type_generics {
|
let type_generics_tokens = if self.include_type_generics {
|
||||||
|
|
Loading…
Reference in a new issue