Make Clippy almost happy on latest Rust
This commit is contained in:
parent
dc99ae70b8
commit
70bc9c4512
21 changed files with 100 additions and 156 deletions
|
@ -146,7 +146,9 @@ pub enum Definition<'a, S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub type Document<'a, S> = Vec<Definition<'a, S>>;
|
pub type Document<'a, S> = [Definition<'a, S>];
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub type OwnedDocument<'a, S> = Vec<Definition<'a, S>>;
|
||||||
|
|
||||||
/// Parse an unstructured input value into a Rust data type.
|
/// Parse an unstructured input value into a Rust data type.
|
||||||
///
|
///
|
||||||
|
@ -381,7 +383,7 @@ where
|
||||||
///
|
///
|
||||||
/// This constructs a new IndexMap that contain references to the keys
|
/// This constructs a new IndexMap that contain references to the keys
|
||||||
/// and values in `self`.
|
/// and values in `self`.
|
||||||
pub fn to_object_value<'a>(&'a self) -> Option<IndexMap<&'a str, &'a Self>> {
|
pub fn to_object_value(&self) -> Option<IndexMap<&str, &Self>> {
|
||||||
match *self {
|
match *self {
|
||||||
InputValue::Object(ref o) => Some(
|
InputValue::Object(ref o) => Some(
|
||||||
o.iter()
|
o.iter()
|
||||||
|
|
|
@ -440,7 +440,7 @@ impl<'a, S> LookAheadMethods<'a, S> for LookAheadSelection<'a, S> {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::Document,
|
ast::{Document, OwnedDocument},
|
||||||
parser::UnlocatedParseResult,
|
parser::UnlocatedParseResult,
|
||||||
schema::model::SchemaType,
|
schema::model::SchemaType,
|
||||||
validation::test_harness::{MutationRoot, QueryRoot, SubscriptionRoot},
|
validation::test_harness::{MutationRoot, QueryRoot, SubscriptionRoot},
|
||||||
|
@ -448,7 +448,7 @@ mod tests {
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
fn parse_document_source<S>(q: &str) -> UnlocatedParseResult<Document<S>>
|
fn parse_document_source<S>(q: &str) -> UnlocatedParseResult<OwnedDocument<S>>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
{
|
{
|
||||||
|
|
|
@ -326,6 +326,7 @@ where
|
||||||
{
|
{
|
||||||
type Type = T;
|
type Type = T;
|
||||||
|
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
fn into(self, _: &'a C) -> FieldResult<Option<(&'a T::Context, Option<T>)>, S> {
|
fn into(self, _: &'a C) -> FieldResult<Option<(&'a T::Context, Option<T>)>, S> {
|
||||||
Ok(self.map(|(ctx, v)| (ctx, Some(v))))
|
Ok(self.map(|(ctx, v)| (ctx, Some(v))))
|
||||||
}
|
}
|
||||||
|
@ -353,6 +354,7 @@ where
|
||||||
{
|
{
|
||||||
type Type = T;
|
type Type = T;
|
||||||
|
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
fn into(self, _: &'a C) -> FieldResult<Option<(&'a T::Context, Option<T>)>, S2> {
|
fn into(self, _: &'a C) -> FieldResult<Option<(&'a T::Context, Option<T>)>, S2> {
|
||||||
self.map(|o| o.map(|(ctx, v)| (ctx, Some(v))))
|
self.map(|o| o.map(|(ctx, v)| (ctx, Some(v))))
|
||||||
.map_err(FieldError::map_scalar_value)
|
.map_err(FieldError::map_scalar_value)
|
||||||
|
|
|
@ -112,16 +112,8 @@ where
|
||||||
Executor {
|
Executor {
|
||||||
fragments: &self.fragments,
|
fragments: &self.fragments,
|
||||||
variables: &self.variables,
|
variables: &self.variables,
|
||||||
current_selection_set: if let Some(s) = &self.current_selection_set {
|
current_selection_set: self.current_selection_set.as_deref(),
|
||||||
Some(&s[..])
|
parent_selection_set: self.parent_selection_set.as_deref(),
|
||||||
} else {
|
|
||||||
None
|
|
||||||
},
|
|
||||||
parent_selection_set: if let Some(s) = &self.parent_selection_set {
|
|
||||||
Some(&s[..])
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
},
|
|
||||||
current_type: self.current_type.clone(),
|
current_type: self.current_type.clone(),
|
||||||
schema: self.schema,
|
schema: self.schema,
|
||||||
context: self.context,
|
context: self.context,
|
||||||
|
|
|
@ -319,7 +319,7 @@ where
|
||||||
SubscriptionT::TypeInfo: Sync,
|
SubscriptionT::TypeInfo: Sync,
|
||||||
S: ScalarValue + Send + Sync,
|
S: ScalarValue + Send + Sync,
|
||||||
{
|
{
|
||||||
let document: crate::ast::Document<'a, S> =
|
let document: crate::ast::OwnedDocument<'a, S> =
|
||||||
parse_document_source(document_source, &root_node.schema)?;
|
parse_document_source(document_source, &root_node.schema)?;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::ast::{
|
use crate::ast::{
|
||||||
Arguments, Definition, Directive, Document, Field, Fragment, FragmentSpread, InlineFragment,
|
Arguments, Definition, Directive, Field, Fragment, FragmentSpread, InlineFragment, InputValue,
|
||||||
InputValue, Operation, OperationType, Selection, Type, VariableDefinition, VariableDefinitions,
|
Operation, OperationType, OwnedDocument, Selection, Type, VariableDefinition,
|
||||||
|
VariableDefinitions,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -21,7 +22,7 @@ use crate::{
|
||||||
pub fn parse_document_source<'a, 'b, S>(
|
pub fn parse_document_source<'a, 'b, S>(
|
||||||
s: &'a str,
|
s: &'a str,
|
||||||
schema: &'b SchemaType<'b, S>,
|
schema: &'b SchemaType<'b, S>,
|
||||||
) -> UnlocatedParseResult<'a, Document<'a, S>>
|
) -> UnlocatedParseResult<'a, OwnedDocument<'a, S>>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
{
|
{
|
||||||
|
@ -33,7 +34,7 @@ where
|
||||||
fn parse_document<'a, 'b, S>(
|
fn parse_document<'a, 'b, S>(
|
||||||
parser: &mut Parser<'a>,
|
parser: &mut Parser<'a>,
|
||||||
schema: &'b SchemaType<'b, S>,
|
schema: &'b SchemaType<'b, S>,
|
||||||
) -> UnlocatedParseResult<'a, Document<'a, S>>
|
) -> UnlocatedParseResult<'a, OwnedDocument<'a, S>>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{
|
ast::{
|
||||||
Arguments, Definition, Document, Field, InputValue, Operation, OperationType, Selection,
|
Arguments, Definition, Field, InputValue, Operation, OperationType, OwnedDocument,
|
||||||
|
Selection,
|
||||||
},
|
},
|
||||||
parser::{document::parse_document_source, ParseError, SourcePosition, Spanning, Token},
|
parser::{document::parse_document_source, ParseError, SourcePosition, Spanning, Token},
|
||||||
schema::model::SchemaType,
|
schema::model::SchemaType,
|
||||||
|
@ -9,7 +10,7 @@ use crate::{
|
||||||
value::{DefaultScalarValue, ScalarValue},
|
value::{DefaultScalarValue, ScalarValue},
|
||||||
};
|
};
|
||||||
|
|
||||||
fn parse_document<S>(s: &str) -> Document<S>
|
fn parse_document<S>(s: &str) -> OwnedDocument<S>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
{
|
{
|
||||||
|
|
|
@ -293,14 +293,10 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
|
|
||||||
/// Get the mutation type from the schema.
|
/// Get the mutation type from the schema.
|
||||||
pub fn mutation_type(&self) -> Option<TypeType<S>> {
|
pub fn mutation_type(&self) -> Option<TypeType<S>> {
|
||||||
if let Some(ref mutation_type_name) = self.mutation_type_name {
|
self.mutation_type_name.as_ref().map(|name| {
|
||||||
Some(
|
self.type_by_name(name)
|
||||||
self.type_by_name(mutation_type_name)
|
.expect("Mutation type does not exist in schema")
|
||||||
.expect("Mutation type does not exist in schema"),
|
})
|
||||||
)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the concrete mutation type from the schema.
|
/// Get the concrete mutation type from the schema.
|
||||||
|
@ -313,14 +309,10 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
|
|
||||||
/// Get the subscription type.
|
/// Get the subscription type.
|
||||||
pub fn subscription_type(&self) -> Option<TypeType<S>> {
|
pub fn subscription_type(&self) -> Option<TypeType<S>> {
|
||||||
if let Some(ref subscription_type_name) = self.subscription_type_name {
|
self.subscription_type_name.as_ref().map(|name| {
|
||||||
Some(
|
self.type_by_name(name)
|
||||||
self.type_by_name(subscription_type_name)
|
.expect("Subscription type does not exist in schema")
|
||||||
.expect("Subscription type does not exist in schema"),
|
})
|
||||||
)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the concrete subscription type.
|
/// Get the concrete subscription type.
|
||||||
|
|
|
@ -299,7 +299,6 @@ where
|
||||||
S: ScalarValue + Send + Sync,
|
S: ScalarValue + Send + Sync,
|
||||||
{
|
{
|
||||||
use futures::stream::{FuturesOrdered, StreamExt as _};
|
use futures::stream::{FuturesOrdered, StreamExt as _};
|
||||||
use std::iter::FromIterator;
|
|
||||||
|
|
||||||
let stop_on_null = executor
|
let stop_on_null = executor
|
||||||
.current_type()
|
.current_type()
|
||||||
|
@ -307,8 +306,9 @@ where
|
||||||
.expect("Current type is not a list type")
|
.expect("Current type is not a list type")
|
||||||
.is_non_null();
|
.is_non_null();
|
||||||
|
|
||||||
let iter = items.map(|it| async move { executor.resolve_into_value_async(info, it).await });
|
let mut futures = items
|
||||||
let mut futures = FuturesOrdered::from_iter(iter);
|
.map(|it| async move { executor.resolve_into_value_async(info, it).await })
|
||||||
|
.collect::<FuturesOrdered<_>>();
|
||||||
|
|
||||||
let mut values = Vec::with_capacity(futures.len());
|
let mut values = Vec::with_capacity(futures.len());
|
||||||
while let Some(value) = futures.next().await {
|
while let Some(value) = futures.next().await {
|
||||||
|
|
|
@ -94,10 +94,7 @@ where
|
||||||
T: FromInputValue<S>,
|
T: FromInputValue<S>,
|
||||||
{
|
{
|
||||||
fn from_input_value(v: &InputValue<S>) -> Option<Box<T>> {
|
fn from_input_value(v: &InputValue<S>) -> Option<Box<T>> {
|
||||||
match <T as FromInputValue<S>>::from_input_value(v) {
|
<T as FromInputValue<S>>::from_input_value(v).map(Box::new)
|
||||||
Some(v) => Some(Box::new(v)),
|
|
||||||
None => None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,10 +286,7 @@ where
|
||||||
T: FromInputValue<S>,
|
T: FromInputValue<S>,
|
||||||
{
|
{
|
||||||
fn from_input_value(v: &InputValue<S>) -> Option<Arc<T>> {
|
fn from_input_value(v: &InputValue<S>) -> Option<Arc<T>> {
|
||||||
match <T as FromInputValue<S>>::from_input_value(v) {
|
<T as FromInputValue<S>>::from_input_value(v).map(Arc::new)
|
||||||
Some(v) => Some(Arc::new(v)),
|
|
||||||
None => None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,19 +230,11 @@ where
|
||||||
self.1.exit_list_value(ctx, l);
|
self.1.exit_list_value(ctx, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enter_object_value(
|
fn enter_object_value(&mut self, ctx: &mut ValidatorContext<'a, S>, o: SpannedObject<'a, S>) {
|
||||||
&mut self,
|
|
||||||
ctx: &mut ValidatorContext<'a, S>,
|
|
||||||
o: Spanning<&'a Vec<(Spanning<String>, Spanning<InputValue<S>>)>>,
|
|
||||||
) {
|
|
||||||
self.0.enter_object_value(ctx, o);
|
self.0.enter_object_value(ctx, o);
|
||||||
self.1.enter_object_value(ctx, o);
|
self.1.enter_object_value(ctx, o);
|
||||||
}
|
}
|
||||||
fn exit_object_value(
|
fn exit_object_value(&mut self, ctx: &mut ValidatorContext<'a, S>, o: SpannedObject<'a, S>) {
|
||||||
&mut self,
|
|
||||||
ctx: &mut ValidatorContext<'a, S>,
|
|
||||||
o: Spanning<&'a Vec<(Spanning<String>, Spanning<InputValue<S>>)>>,
|
|
||||||
) {
|
|
||||||
self.0.exit_object_value(ctx, o);
|
self.0.exit_object_value(ctx, o);
|
||||||
self.1.exit_object_value(ctx, o);
|
self.1.exit_object_value(ctx, o);
|
||||||
}
|
}
|
||||||
|
@ -264,3 +256,5 @@ where
|
||||||
self.1.exit_object_field(ctx, f);
|
self.1.exit_object_field(ctx, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SpannedObject<'a, S> = Spanning<&'a Vec<(Spanning<String>, Spanning<InputValue<S>>)>>;
|
||||||
|
|
|
@ -21,19 +21,11 @@ impl<'a, S> Visitor<'a, S> for UniqueInputFieldNames<'a>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
{
|
{
|
||||||
fn enter_object_value(
|
fn enter_object_value(&mut self, _: &mut ValidatorContext<'a, S>, _: SpannedObject<'a, S>) {
|
||||||
&mut self,
|
|
||||||
_: &mut ValidatorContext<'a, S>,
|
|
||||||
_: Spanning<&'a Vec<(Spanning<String>, Spanning<InputValue<S>>)>>,
|
|
||||||
) {
|
|
||||||
self.known_name_stack.push(HashMap::new());
|
self.known_name_stack.push(HashMap::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exit_object_value(
|
fn exit_object_value(&mut self, _: &mut ValidatorContext<'a, S>, _: SpannedObject<'a, S>) {
|
||||||
&mut self,
|
|
||||||
_: &mut ValidatorContext<'a, S>,
|
|
||||||
_: Spanning<&'a Vec<(Spanning<String>, Spanning<InputValue<S>>)>>,
|
|
||||||
) {
|
|
||||||
self.known_name_stack.pop();
|
self.known_name_stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +50,8 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SpannedObject<'a, S> = Spanning<&'a Vec<(Spanning<String>, Spanning<InputValue<S>>)>>;
|
||||||
|
|
||||||
fn error_message(field_name: &str) -> String {
|
fn error_message(field_name: &str) -> String {
|
||||||
format!("There can only be one input field named \"{}\"", field_name)
|
format!("There can only be one input field named \"{}\"", field_name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -865,7 +865,9 @@ where
|
||||||
let mut ctx = ValidatorContext::new(unsafe { ::std::mem::transmute(&root.schema) }, &doc);
|
let mut ctx = ValidatorContext::new(unsafe { ::std::mem::transmute(&root.schema) }, &doc);
|
||||||
|
|
||||||
let mut mv = MultiVisitorNil.with(factory());
|
let mut mv = MultiVisitorNil.with(factory());
|
||||||
visit(&mut mv, &mut ctx, unsafe { ::std::mem::transmute(&doc) });
|
visit(&mut mv, &mut ctx, unsafe {
|
||||||
|
::std::mem::transmute(doc.as_slice())
|
||||||
|
});
|
||||||
|
|
||||||
ctx.into_errors()
|
ctx.into_errors()
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,18 +128,8 @@ where
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enter_object_value(
|
fn enter_object_value(&mut self, _: &mut ValidatorContext<'a, S>, _: SpannedObject<'a, S>) {}
|
||||||
&mut self,
|
fn exit_object_value(&mut self, _: &mut ValidatorContext<'a, S>, _: SpannedObject<'a, S>) {}
|
||||||
_: &mut ValidatorContext<'a, S>,
|
|
||||||
_: Spanning<&'a Vec<(Spanning<String>, Spanning<InputValue<S>>)>>,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
fn exit_object_value(
|
|
||||||
&mut self,
|
|
||||||
_: &mut ValidatorContext<'a, S>,
|
|
||||||
_: Spanning<&'a Vec<(Spanning<String>, Spanning<InputValue<S>>)>>,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn enter_object_field(
|
fn enter_object_field(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -154,3 +144,5 @@ where
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SpannedObject<'a, S> = Spanning<&'a Vec<(Spanning<String>, Spanning<InputValue<S>>)>>;
|
||||||
|
|
|
@ -73,10 +73,7 @@ where
|
||||||
operation_name,
|
operation_name,
|
||||||
variables,
|
variables,
|
||||||
} = get_req;
|
} = get_req;
|
||||||
let variables = match variables {
|
let variables = variables.map(|s| serde_json::from_str(&s).unwrap());
|
||||||
Some(variables) => Some(serde_json::from_str(&variables).unwrap()),
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
Self::new(query, operation_name, variables)
|
Self::new(query, operation_name, variables)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,9 @@ struct ScalarCodegenInput {
|
||||||
fn get_first_method_arg(
|
fn get_first_method_arg(
|
||||||
inputs: syn::punctuated::Punctuated<syn::FnArg, syn::Token![,]>,
|
inputs: syn::punctuated::Punctuated<syn::FnArg, syn::Token![,]>,
|
||||||
) -> Option<syn::Ident> {
|
) -> Option<syn::Ident> {
|
||||||
if let Some(fn_arg) = inputs.first() {
|
if let Some(syn::FnArg::Typed(pat_type)) = inputs.first() {
|
||||||
if let syn::FnArg::Typed(pat_type) = fn_arg {
|
if let syn::Pat::Ident(pat_ident) = &*pat_type.pat {
|
||||||
if let syn::Pat::Ident(pat_ident) = &*pat_type.pat {
|
return Some(pat_ident.ident.clone());
|
||||||
return Some(pat_ident.ident.clone());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,39 +43,27 @@ fn get_method_return_type(output: syn::ReturnType) -> Option<syn::Type> {
|
||||||
|
|
||||||
// Find the enum type by inspecting the type parameter on the return value
|
// Find the enum type by inspecting the type parameter on the return value
|
||||||
fn get_enum_type(return_type: &Option<syn::Type>) -> Option<syn::PathSegment> {
|
fn get_enum_type(return_type: &Option<syn::Type>) -> Option<syn::PathSegment> {
|
||||||
if let Some(return_type) = return_type {
|
if let Some(syn::Type::Path(type_path)) = return_type {
|
||||||
match return_type {
|
let path_segment = type_path
|
||||||
syn::Type::Path(type_path) => {
|
.path
|
||||||
let path_segment = type_path
|
.segments
|
||||||
.path
|
.iter()
|
||||||
.segments
|
.find(|ps| matches!(ps.arguments, syn::PathArguments::AngleBracketed(_)));
|
||||||
.iter()
|
|
||||||
.find(|ps| match ps.arguments {
|
|
||||||
syn::PathArguments::AngleBracketed(_) => true,
|
|
||||||
_ => false,
|
|
||||||
});
|
|
||||||
|
|
||||||
if let Some(path_segment) = path_segment {
|
if let Some(path_segment) = path_segment {
|
||||||
match &path_segment.arguments {
|
if let syn::PathArguments::AngleBracketed(generic_args) = &path_segment.arguments {
|
||||||
syn::PathArguments::AngleBracketed(generic_args) => {
|
let generic_type_arg = generic_args.args.iter().find(|generic_type_arg| {
|
||||||
let generic_type_arg =
|
matches!(generic_type_arg, syn::GenericArgument::Type(_))
|
||||||
generic_args.args.iter().find(|generic_type_arg| {
|
});
|
||||||
matches!(generic_type_arg, syn::GenericArgument::Type(_))
|
|
||||||
});
|
|
||||||
|
|
||||||
if let Some(syn::GenericArgument::Type(syn::Type::Path(type_path))) =
|
if let Some(syn::GenericArgument::Type(syn::Type::Path(type_path))) =
|
||||||
generic_type_arg
|
generic_type_arg
|
||||||
{
|
{
|
||||||
if let Some(path_segment) = type_path.path.segments.first() {
|
if let Some(path_segment) = type_path.path.segments.first() {
|
||||||
return Some(path_segment.clone());
|
return Some(path_segment.clone());
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,8 +95,8 @@ impl syn::parse::Parse for ScalarCodegenInput {
|
||||||
}
|
}
|
||||||
|
|
||||||
for impl_item in parse_custom_scalar_value_impl.items {
|
for impl_item in parse_custom_scalar_value_impl.items {
|
||||||
match impl_item {
|
if let syn::ImplItem::Method(method) = impl_item {
|
||||||
syn::ImplItem::Method(method) => match method.sig.ident.to_string().as_str() {
|
match method.sig.ident.to_string().as_str() {
|
||||||
"resolve" => {
|
"resolve" => {
|
||||||
resolve_body = Some(method.block);
|
resolve_body = Some(method.block);
|
||||||
}
|
}
|
||||||
|
@ -130,9 +116,8 @@ impl syn::parse::Parse for ScalarCodegenInput {
|
||||||
from_str_body = Some(method.block);
|
from_str_body = Some(method.block);
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
},
|
}
|
||||||
_ => (),
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let custom_data_type = if custom_data_type_is_struct {
|
let custom_data_type = if custom_data_type_is_struct {
|
||||||
|
|
|
@ -161,7 +161,7 @@ fn join_doc_strings(docs: &[String]) -> String {
|
||||||
docs.iter()
|
docs.iter()
|
||||||
.map(|s| s.as_str().trim_end())
|
.map(|s| s.as_str().trim_end())
|
||||||
// Trim leading space.
|
// Trim leading space.
|
||||||
.map(|s| if s.starts_with(' ') { &s[1..] } else { s })
|
.map(|s| s.strip_prefix(' ').unwrap_or(s))
|
||||||
// Add newline, exept when string ends in a continuation backslash or is the last line.
|
// Add newline, exept when string ends in a continuation backslash or is the last line.
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.fold(String::new(), |mut buffer, (index, s)| {
|
.fold(String::new(), |mut buffer, (index, s)| {
|
||||||
|
@ -227,13 +227,11 @@ pub fn to_camel_case(s: &str) -> String {
|
||||||
|
|
||||||
// Handle `_` and `__` to be more friendly with the `_var` convention for unused variables, and
|
// Handle `_` and `__` to be more friendly with the `_var` convention for unused variables, and
|
||||||
// GraphQL introspection identifiers.
|
// GraphQL introspection identifiers.
|
||||||
let s_iter = if s.starts_with("__") {
|
let s_iter = if let Some(s) = s.strip_prefix("__") {
|
||||||
dest.push_str("__");
|
dest.push_str("__");
|
||||||
&s[2..]
|
|
||||||
} else if s.starts_with('_') {
|
|
||||||
&s[1..]
|
|
||||||
} else {
|
|
||||||
s
|
s
|
||||||
|
} else {
|
||||||
|
s.strip_prefix('_').unwrap_or(s)
|
||||||
}
|
}
|
||||||
.split('_')
|
.split('_')
|
||||||
.enumerate();
|
.enumerate();
|
||||||
|
@ -434,9 +432,10 @@ impl ObjectAttributes {
|
||||||
}
|
}
|
||||||
Ok(a)
|
Ok(a)
|
||||||
} else {
|
} else {
|
||||||
let mut a = Self::default();
|
Ok(Self {
|
||||||
a.description = get_doc_comment(attrs);
|
description: get_doc_comment(attrs),
|
||||||
Ok(a)
|
..Self::default()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,7 +499,7 @@ enum FieldAttribute {
|
||||||
Deprecation(SpanContainer<DeprecationAttr>),
|
Deprecation(SpanContainer<DeprecationAttr>),
|
||||||
Skip(SpanContainer<syn::Ident>),
|
Skip(SpanContainer<syn::Ident>),
|
||||||
Arguments(HashMap<String, FieldAttributeArgument>),
|
Arguments(HashMap<String, FieldAttributeArgument>),
|
||||||
Default(SpanContainer<Option<syn::Expr>>),
|
Default(Box<SpanContainer<Option<syn::Expr>>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for FieldAttribute {
|
impl Parse for FieldAttribute {
|
||||||
|
@ -573,7 +572,7 @@ impl Parse for FieldAttribute {
|
||||||
SpanContainer::new(ident.span(), None, None)
|
SpanContainer::new(ident.span(), None, None)
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(FieldAttribute::Default(default_expr))
|
Ok(FieldAttribute::Default(Box::new(default_expr)))
|
||||||
}
|
}
|
||||||
_ => Err(syn::Error::new(ident.span(), "unknown attribute")),
|
_ => Err(syn::Error::new(ident.span(), "unknown attribute")),
|
||||||
}
|
}
|
||||||
|
@ -617,7 +616,7 @@ impl Parse for FieldAttributes {
|
||||||
output.arguments = args;
|
output.arguments = args;
|
||||||
}
|
}
|
||||||
FieldAttribute::Default(expr) => {
|
FieldAttribute::Default(expr) => {
|
||||||
output.default = Some(expr);
|
output.default = Some(*expr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ impl<T: ToTokens> ToTokens for SpanContainer<T> {
|
||||||
|
|
||||||
impl<T> SpanContainer<T> {
|
impl<T> SpanContainer<T> {
|
||||||
pub fn new(ident: Span, expr: Option<Span>, val: T) -> Self {
|
pub fn new(ident: Span, expr: Option<Span>, val: T) -> Self {
|
||||||
Self { ident, expr, val }
|
Self { expr, ident, val }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn span_ident(&self) -> Span {
|
pub fn span_ident(&self) -> Span {
|
||||||
|
|
|
@ -486,6 +486,7 @@ enum ConnectionSinkState<S: Schema, I: Init<S::ScalarValue, S::Context>> {
|
||||||
state: ConnectionState<S, I>,
|
state: ConnectionState<S, I>,
|
||||||
},
|
},
|
||||||
HandlingMessage {
|
HandlingMessage {
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
result: BoxFuture<'static, (ConnectionState<S, I>, BoxStream<'static, Reaction<S>>)>,
|
result: BoxFuture<'static, (ConnectionState<S, I>, BoxStream<'static, Reaction<S>>)>,
|
||||||
},
|
},
|
||||||
Closed,
|
Closed,
|
||||||
|
@ -607,26 +608,22 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// Poll the reactions for new outgoing messages.
|
// Poll the reactions for new outgoing messages.
|
||||||
loop {
|
if !self.reactions.is_empty() {
|
||||||
if !self.reactions.is_empty() {
|
match Pin::new(&mut self.reactions).poll_next(cx) {
|
||||||
match Pin::new(&mut self.reactions).poll_next(cx) {
|
Poll::Ready(Some(reaction)) => match reaction {
|
||||||
Poll::Ready(Some(reaction)) => match reaction {
|
Reaction::ServerMessage(msg) => return Poll::Ready(Some(msg)),
|
||||||
Reaction::ServerMessage(msg) => return Poll::Ready(Some(msg)),
|
Reaction::EndStream => return Poll::Ready(None),
|
||||||
Reaction::EndStream => return Poll::Ready(None),
|
},
|
||||||
},
|
Poll::Ready(None) => {
|
||||||
Poll::Ready(None) => {
|
// In rare cases, the reaction stream may terminate. For example, this will
|
||||||
// In rare cases, the reaction stream may terminate. For example, this will
|
// happen if the first message we receive does not require any reaction. Just
|
||||||
// happen if the first message we receive does not require any reaction. Just
|
// recreate it in that case.
|
||||||
// recreate it in that case.
|
self.reactions = SelectAll::new();
|
||||||
self.reactions = SelectAll::new();
|
|
||||||
return Poll::Pending;
|
|
||||||
}
|
|
||||||
Poll::Pending => return Poll::Pending,
|
|
||||||
}
|
}
|
||||||
} else {
|
_ => (),
|
||||||
return Poll::Pending;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Poll::Pending
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,9 @@ pub struct ErrorPayload {
|
||||||
impl ErrorPayload {
|
impl ErrorPayload {
|
||||||
/// For this to be okay, the caller must guarantee that the error can only reference data from
|
/// For this to be okay, the caller must guarantee that the error can only reference data from
|
||||||
/// execution_params and that execution_params has not been modified or moved.
|
/// execution_params and that execution_params has not been modified or moved.
|
||||||
pub(crate) unsafe fn new_unchecked<'a>(
|
pub(crate) unsafe fn new_unchecked(
|
||||||
execution_params: Box<dyn Any + Send>,
|
execution_params: Box<dyn Any + Send>,
|
||||||
error: GraphQLError<'a>,
|
error: GraphQLError<'_>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
_execution_params: Some(execution_params),
|
_execution_params: Some(execution_params),
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
merge_imports = true
|
imports_granularity = "Crate"
|
||||||
use_field_init_shorthand = true
|
use_field_init_shorthand = true
|
||||||
|
|
Loading…
Reference in a new issue