Struct async_graphql::context::QueryPathNode
source · pub struct QueryPathNode<'a> {
pub parent: Option<&'a QueryPathNode<'a>>,
pub segment: QueryPathSegment<'a>,
}
Expand description
A path to the current query.
The path is stored as a kind of reverse linked list.
Fields§
§parent: Option<&'a QueryPathNode<'a>>
The parent node to this, if there is one.
segment: QueryPathSegment<'a>
The current path segment being resolved.
Implementations§
source§impl<'a> QueryPathNode<'a>
impl<'a> QueryPathNode<'a>
sourcepub fn field_name(&self) -> &str
pub fn field_name(&self) -> &str
Get the current field name.
This traverses all the parents of the node until it finds one that is a field name.
Examples found in repository?
src/extensions/apollo_tracing.rs (line 110)
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
async fn resolve(
&self,
ctx: &ExtensionContext<'_>,
info: ResolveInfo<'_>,
next: NextResolve<'_>,
) -> ServerResult<Option<Value>> {
let path = info.path_node.to_string_vec();
let field_name = info.path_node.field_name().to_string();
let parent_type = info.parent_type.to_string();
let return_type = info.return_type.to_string();
let start_time = Utc::now();
let start_offset = (start_time - self.inner.lock().await.start_time)
.num_nanoseconds()
.unwrap();
let res = next.run(ctx, info).await;
let end_time = Utc::now();
self.inner.lock().await.resolves.push(ResolveState {
path,
field_name,
parent_type,
return_type,
start_time,
end_time,
start_offset,
});
res
}
sourcepub fn to_string_vec(self) -> Vec<String> ⓘ
pub fn to_string_vec(self) -> Vec<String> ⓘ
Get the path represented by Vec<String>
; numbers will be stringified.
Examples found in repository?
src/extensions/apollo_tracing.rs (line 109)
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
async fn resolve(
&self,
ctx: &ExtensionContext<'_>,
info: ResolveInfo<'_>,
next: NextResolve<'_>,
) -> ServerResult<Option<Value>> {
let path = info.path_node.to_string_vec();
let field_name = info.path_node.field_name().to_string();
let parent_type = info.parent_type.to_string();
let return_type = info.return_type.to_string();
let start_time = Utc::now();
let start_offset = (start_time - self.inner.lock().await.start_time)
.num_nanoseconds()
.unwrap();
let res = next.run(ctx, info).await;
let end_time = Utc::now();
self.inner.lock().await.resolves.push(ResolveState {
path,
field_name,
parent_type,
return_type,
start_time,
end_time,
start_offset,
});
res
}
Trait Implementations§
source§impl<'a> Clone for QueryPathNode<'a>
impl<'a> Clone for QueryPathNode<'a>
source§fn clone(&self) -> QueryPathNode<'a>
fn clone(&self) -> QueryPathNode<'a>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more