Add context to ResolveInfo. #260
This commit is contained in:
parent
175a48875e
commit
a4a5847d4f
|
@ -201,7 +201,8 @@ impl<'a> std::fmt::Display for QueryPathNode<'a> {
|
|||
}
|
||||
|
||||
impl<'a> QueryPathNode<'a> {
|
||||
pub(crate) fn field_name(&self) -> &str {
|
||||
/// Get the current field name.
|
||||
pub fn field_name(&self) -> &str {
|
||||
let mut p = self;
|
||||
loop {
|
||||
if let QueryPathSegment::Name(name) = &p.segment {
|
||||
|
|
|
@ -5,7 +5,7 @@ mod logger;
|
|||
mod tracing;
|
||||
|
||||
use crate::context::{QueryPathNode, ResolveId};
|
||||
use crate::{Result, Variables};
|
||||
use crate::{Context, Result, Variables};
|
||||
|
||||
pub use self::apollo_tracing::ApolloTracing;
|
||||
pub use self::logger::Logger;
|
||||
|
@ -28,6 +28,9 @@ pub struct ResolveInfo<'a> {
|
|||
/// Current path node, You can go through the entire path.
|
||||
pub path_node: &'a QueryPathNode<'a>,
|
||||
|
||||
/// Context
|
||||
pub context: &'a Context<'a>,
|
||||
|
||||
/// Parent type
|
||||
pub parent_type: &'a str,
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ fn do_resolve<'a, T: ObjectType + Send + Sync>(
|
|||
let resolve_info = ResolveInfo {
|
||||
resolve_id: ctx_field.resolve_id,
|
||||
path_node: ctx_field.path_node.as_ref().unwrap(),
|
||||
context: &ctx_field,
|
||||
parent_type: &T::type_name(),
|
||||
return_type: match ctx_field
|
||||
.schema_env
|
||||
|
|
|
@ -83,6 +83,7 @@ pub fn collect_fields<'a, T: ObjectType + Send + Sync>(
|
|||
let resolve_info = ResolveInfo {
|
||||
resolve_id: ctx_field.resolve_id,
|
||||
path_node: ctx_field.path_node.as_ref().unwrap(),
|
||||
context: &ctx_field,
|
||||
parent_type: &T::type_name(),
|
||||
return_type: match ctx_field
|
||||
.schema_env
|
||||
|
|
Loading…
Reference in New Issue
Block a user