This commit is contained in:
Koxiaet 2020-10-15 06:56:17 +01:00
parent 4eaa9cb86e
commit cc115ff1a7
2 changed files with 14 additions and 10 deletions

View File

@ -188,20 +188,24 @@ impl<'a> QueryPathNode<'a> {
///
/// This traverses all the parents of the node until it finds one that is a field name.
pub fn field_name(&self) -> &str {
self.parents().find_map(|node| match node.segment {
QueryPathSegment::Name(name) => Some(name),
QueryPathSegment::Index(_) => None,
}).unwrap()
self.parents()
.find_map(|node| match node.segment {
QueryPathSegment::Name(name) => Some(name),
QueryPathSegment::Index(_) => None,
})
.unwrap()
}
/// Get the path represented by `Vec<String>`; numbers will be stringified.
#[must_use]
pub fn to_string_vec(&self) -> Vec<String> {
let mut res = Vec::new();
self.for_each(|s| res.push(match s {
QueryPathSegment::Name(name) => name.to_string(),
QueryPathSegment::Index(idx) => idx.to_string(),
}));
self.for_each(|s| {
res.push(match s {
QueryPathSegment::Name(name) => name.to_string(),
QueryPathSegment::Index(idx) => idx.to_string(),
})
});
res
}

View File

@ -122,8 +122,8 @@ mod schema;
mod subscription;
mod validation;
pub mod extensions;
pub mod context;
pub mod extensions;
pub mod guard;
pub mod http;
pub mod resolver_utils;
@ -169,9 +169,9 @@ pub use response::{BatchResponse, Response};
pub use schema::{Schema, SchemaBuilder, SchemaEnv};
pub use validation::ValidationMode;
pub use context::*;
#[doc(no_inline)]
pub use parser::{Pos, Positioned};
pub use context::*;
pub use types::*;
/// An alias of [async_graphql::Error](struct.Error.html). Present for backward compatibility