Fix some clippy warnings (#595)
This commit is contained in:
parent
dbe2c67cb8
commit
adc8d7be2d
9 changed files with 40 additions and 24 deletions
|
@ -353,7 +353,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// View the underlying string value, if present.
|
/// View the underlying string value, if present.
|
||||||
pub fn as_string_value<'a>(&'a self) -> Option<&'a str> {
|
pub fn as_string_value(&self) -> Option<&str> {
|
||||||
self.as_scalar_value().and_then(|s| s.as_str())
|
self.as_scalar_value().and_then(|s| s.as_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -620,7 +620,7 @@ where
|
||||||
self.field_path.construct_path(&mut path);
|
self.field_path.construct_path(&mut path);
|
||||||
|
|
||||||
ExecutionError {
|
ExecutionError {
|
||||||
location: self.location().clone(),
|
location: *self.location(),
|
||||||
path,
|
path,
|
||||||
error,
|
error,
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,6 +139,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, S> SchemaType<'a, S> {
|
impl<'a, S> SchemaType<'a, S> {
|
||||||
|
/// Create a new schema.
|
||||||
pub fn new<QueryT, MutationT, SubscriptionT>(
|
pub fn new<QueryT, MutationT, SubscriptionT>(
|
||||||
query_info: &QueryT::TypeInfo,
|
query_info: &QueryT::TypeInfo,
|
||||||
mutation_info: &MutationT::TypeInfo,
|
mutation_info: &MutationT::TypeInfo,
|
||||||
|
@ -218,14 +219,17 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add a directive like `skip` or `include`.
|
||||||
pub fn add_directive(&mut self, directive: DirectiveType<'a, S>) {
|
pub fn add_directive(&mut self, directive: DirectiveType<'a, S>) {
|
||||||
self.directives.insert(directive.name.clone(), directive);
|
self.directives.insert(directive.name.clone(), directive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a type by name.
|
||||||
pub fn type_by_name(&self, name: &str) -> Option<TypeType<S>> {
|
pub fn type_by_name(&self, name: &str) -> Option<TypeType<S>> {
|
||||||
self.types.get(name).map(|t| TypeType::Concrete(t))
|
self.types.get(name).map(|t| TypeType::Concrete(t))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a concrete type by name.
|
||||||
pub fn concrete_type_by_name(&self, name: &str) -> Option<&MetaType<S>> {
|
pub fn concrete_type_by_name(&self, name: &str) -> Option<&MetaType<S>> {
|
||||||
self.types.get(name)
|
self.types.get(name)
|
||||||
}
|
}
|
||||||
|
@ -239,6 +243,7 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the query type from the schema.
|
||||||
pub fn query_type(&self) -> TypeType<S> {
|
pub fn query_type(&self) -> TypeType<S> {
|
||||||
TypeType::Concrete(
|
TypeType::Concrete(
|
||||||
self.types
|
self.types
|
||||||
|
@ -247,12 +252,14 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the concrete query type from the schema.
|
||||||
pub fn concrete_query_type(&self) -> &MetaType<S> {
|
pub fn concrete_query_type(&self) -> &MetaType<S> {
|
||||||
self.types
|
self.types
|
||||||
.get(&self.query_type_name)
|
.get(&self.query_type_name)
|
||||||
.expect("Query type does not exist in schema")
|
.expect("Query type does not exist in 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 {
|
if let Some(ref mutation_type_name) = self.mutation_type_name {
|
||||||
Some(
|
Some(
|
||||||
|
@ -264,6 +271,7 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the concrete mutation type from the schema.
|
||||||
pub fn concrete_mutation_type(&self) -> Option<&MetaType<S>> {
|
pub fn concrete_mutation_type(&self) -> Option<&MetaType<S>> {
|
||||||
self.mutation_type_name.as_ref().map(|name| {
|
self.mutation_type_name.as_ref().map(|name| {
|
||||||
self.concrete_type_by_name(name)
|
self.concrete_type_by_name(name)
|
||||||
|
@ -271,6 +279,7 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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 {
|
if let Some(ref subscription_type_name) = self.subscription_type_name {
|
||||||
Some(
|
Some(
|
||||||
|
@ -282,6 +291,7 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the concrete subscription type.
|
||||||
pub fn concrete_subscription_type(&self) -> Option<&MetaType<S>> {
|
pub fn concrete_subscription_type(&self) -> Option<&MetaType<S>> {
|
||||||
self.subscription_type_name.as_ref().map(|name| {
|
self.subscription_type_name.as_ref().map(|name| {
|
||||||
self.concrete_type_by_name(name)
|
self.concrete_type_by_name(name)
|
||||||
|
@ -289,14 +299,17 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a list of types.
|
||||||
pub fn type_list(&self) -> Vec<TypeType<S>> {
|
pub fn type_list(&self) -> Vec<TypeType<S>> {
|
||||||
self.types.values().map(|t| TypeType::Concrete(t)).collect()
|
self.types.values().map(|t| TypeType::Concrete(t)).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a list of concrete types.
|
||||||
pub fn concrete_type_list(&self) -> Vec<&MetaType<S>> {
|
pub fn concrete_type_list(&self) -> Vec<&MetaType<S>> {
|
||||||
self.types.values().collect()
|
self.types.values().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Make a type.
|
||||||
pub fn make_type(&self, t: &Type) -> TypeType<S> {
|
pub fn make_type(&self, t: &Type) -> TypeType<S> {
|
||||||
match *t {
|
match *t {
|
||||||
Type::NonNullNamed(ref n) => TypeType::NonNull(Box::new(
|
Type::NonNullNamed(ref n) => TypeType::NonNull(Box::new(
|
||||||
|
@ -310,14 +323,17 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a list of directives.
|
||||||
pub fn directive_list(&self) -> Vec<&DirectiveType<S>> {
|
pub fn directive_list(&self) -> Vec<&DirectiveType<S>> {
|
||||||
self.directives.values().collect()
|
self.directives.values().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get directive by name.
|
||||||
pub fn directive_by_name(&self, name: &str) -> Option<&DirectiveType<S>> {
|
pub fn directive_by_name(&self, name: &str) -> Option<&DirectiveType<S>> {
|
||||||
self.directives.get(name)
|
self.directives.get(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Determine if there is an overlap between types.
|
||||||
pub fn type_overlap(&self, t1: &MetaType<S>, t2: &MetaType<S>) -> bool {
|
pub fn type_overlap(&self, t1: &MetaType<S>, t2: &MetaType<S>) -> bool {
|
||||||
if (t1 as *const MetaType<S>) == (t2 as *const MetaType<S>) {
|
if (t1 as *const MetaType<S>) == (t2 as *const MetaType<S>) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -334,6 +350,7 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A list of possible typeees for a given type.
|
||||||
pub fn possible_types(&self, t: &MetaType<S>) -> Vec<&MetaType<S>> {
|
pub fn possible_types(&self, t: &MetaType<S>) -> Vec<&MetaType<S>> {
|
||||||
match *t {
|
match *t {
|
||||||
MetaType::Union(UnionMeta {
|
MetaType::Union(UnionMeta {
|
||||||
|
@ -357,6 +374,7 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If the abstract type is possible.
|
||||||
pub fn is_possible_type(
|
pub fn is_possible_type(
|
||||||
&self,
|
&self,
|
||||||
abstract_type: &MetaType<S>,
|
abstract_type: &MetaType<S>,
|
||||||
|
@ -367,6 +385,7 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
.any(|t| (t as *const MetaType<S>) == (possible_type as *const MetaType<S>))
|
.any(|t| (t as *const MetaType<S>) == (possible_type as *const MetaType<S>))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If the type is a subtype of another type.
|
||||||
pub fn is_subtype<'b>(&self, sub_type: &Type<'b>, super_type: &Type<'b>) -> bool {
|
pub fn is_subtype<'b>(&self, sub_type: &Type<'b>, super_type: &Type<'b>) -> bool {
|
||||||
use crate::ast::Type::*;
|
use crate::ast::Type::*;
|
||||||
|
|
||||||
|
@ -389,6 +408,7 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If the type is a named subtype.
|
||||||
pub fn is_named_subtype(&self, sub_type_name: &str, super_type_name: &str) -> bool {
|
pub fn is_named_subtype(&self, sub_type_name: &str, super_type_name: &str) -> bool {
|
||||||
if sub_type_name == super_type_name {
|
if sub_type_name == super_type_name {
|
||||||
true
|
true
|
||||||
|
|
|
@ -340,6 +340,7 @@ where
|
||||||
///
|
///
|
||||||
/// If you instantiate `RootNode` with this as the subscription,
|
/// If you instantiate `RootNode` with this as the subscription,
|
||||||
/// no subscriptions will be generated for the schema.
|
/// no subscriptions will be generated for the schema.
|
||||||
|
#[derive(Default)]
|
||||||
pub struct EmptySubscription<T> {
|
pub struct EmptySubscription<T> {
|
||||||
phantom: PhantomData<T>,
|
phantom: PhantomData<T>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -364,22 +364,20 @@ where
|
||||||
} else if let Err(e) = sub_result {
|
} else if let Err(e) = sub_result {
|
||||||
sub_exec.push_error_at(e, start_pos.clone());
|
sub_exec.push_error_at(e, start_pos.clone());
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Some(type_name) = meta_type.name() {
|
||||||
if let Some(type_name) = meta_type.name() {
|
let sub_result = instance
|
||||||
let sub_result = instance
|
.resolve_into_type_stream(info, type_name, &sub_exec)
|
||||||
.resolve_into_type_stream(info, type_name, &sub_exec)
|
.await;
|
||||||
.await;
|
|
||||||
|
|
||||||
if let Ok(Value::Object(obj)) = sub_result {
|
if let Ok(Value::Object(obj)) = sub_result {
|
||||||
for (k, v) in obj {
|
for (k, v) in obj {
|
||||||
merge_key_into(&mut object, &k, v);
|
merge_key_into(&mut object, &k, v);
|
||||||
}
|
|
||||||
} else if let Err(e) = sub_result {
|
|
||||||
sub_exec.push_error_at(e, start_pos.clone());
|
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Err(e) = sub_result {
|
||||||
return Value::Null;
|
sub_exec.push_error_at(e, start_pos.clone());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return Value::Null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ impl<'a, S: Debug> VariableInAllowedPosition<'a, S> {
|
||||||
fn collect_incorrect_usages(
|
fn collect_incorrect_usages(
|
||||||
&self,
|
&self,
|
||||||
from: &Scope<'a>,
|
from: &Scope<'a>,
|
||||||
var_defs: &Vec<&'a (Spanning<&'a str>, VariableDefinition<S>)>,
|
var_defs: &[&'a (Spanning<&'a str>, VariableDefinition<S>)],
|
||||||
ctx: &mut ValidatorContext<'a, S>,
|
ctx: &mut ValidatorContext<'a, S>,
|
||||||
visited: &mut HashSet<Scope<'a>>,
|
visited: &mut HashSet<Scope<'a>>,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -388,15 +388,13 @@ pub fn graphql_object_internal(args: TokenStream, input: TokenStream) -> TokenSt
|
||||||
/// A proc macro for defining a GraphQL subscription.
|
/// A proc macro for defining a GraphQL subscription.
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn graphql_subscription(args: TokenStream, input: TokenStream) -> TokenStream {
|
pub fn graphql_subscription(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
let gen = impl_object::build_subscription(args, input, false);
|
impl_object::build_subscription(args, input, false)
|
||||||
gen.into()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn graphql_subscription_internal(args: TokenStream, input: TokenStream) -> TokenStream {
|
pub fn graphql_subscription_internal(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
let gen = impl_object::build_subscription(args, input, true);
|
impl_object::build_subscription(args, input, true)
|
||||||
gen.into()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![doc(html_root_url = "https://docs.rs/juniper_subscriptions/0.14.2")]
|
#![doc(html_root_url = "https://docs.rs/juniper_subscriptions/0.14.2")]
|
||||||
|
|
||||||
use std::{borrow::BorrowMut as _, iter::FromIterator, pin::Pin};
|
use std::{iter::FromIterator, pin::Pin};
|
||||||
|
|
||||||
use futures::{task::Poll, Stream};
|
use futures::{task::Poll, Stream};
|
||||||
use juniper::{
|
use juniper::{
|
||||||
|
@ -197,12 +197,11 @@ where
|
||||||
// TODO: iterate over i and (ref field_name, ref val) once
|
// TODO: iterate over i and (ref field_name, ref val) once
|
||||||
// [this RFC](https://github.com/rust-lang/rust/issues/68354)
|
// [this RFC](https://github.com/rust-lang/rust/issues/68354)
|
||||||
// is implemented
|
// is implemented
|
||||||
for i in 0..obj_len {
|
for ready in ready_vec.iter_mut().take(obj_len) {
|
||||||
let (field_name, val) = match obj_iterator.next() {
|
let (field_name, val) = match obj_iterator.next() {
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
None => break,
|
None => break,
|
||||||
};
|
};
|
||||||
let ready = ready_vec[i].borrow_mut();
|
|
||||||
|
|
||||||
if ready.is_some() {
|
if ready.is_some() {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -343,7 +343,7 @@ where
|
||||||
};
|
};
|
||||||
|
|
||||||
let get_filter = warp::get()
|
let get_filter = warp::get()
|
||||||
.and(context_extractor.clone())
|
.and(context_extractor)
|
||||||
.and(warp::filters::query::query())
|
.and(warp::filters::query::query())
|
||||||
.and_then(handle_get_request);
|
.and_then(handle_get_request);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue