Trait trustfall_core::interpreter::VertexInfo
source · pub trait VertexInfo: __Sealed {
// Required methods
fn vid(&self) -> Vid;
fn coerced_to_type(&self) -> Option<&Arc<str>>;
fn required_properties(
&self
) -> Box<dyn Iterator<Item = RequiredProperty> + '_>;
fn statically_required_property(
&self,
name: &str
) -> Option<CandidateValue<FieldValue>>;
fn dynamically_required_property(
&self,
name: &str
) -> Option<DynamicallyResolvedValue<'_>>;
fn first_mandatory_edge(&self, name: &str) -> Option<EdgeInfo>;
fn first_edge(&self, name: &str) -> Option<EdgeInfo>;
fn edges_with_name<'a>(
&'a self,
name: &'a str
) -> Box<dyn Iterator<Item = EdgeInfo> + 'a>;
fn mandatory_edges_with_name<'a>(
&'a self,
name: &'a str
) -> Box<dyn Iterator<Item = EdgeInfo> + 'a>;
}
Expand description
Information about what the currently-executing query needs at a specific vertex.
Required Methods§
sourcefn vid(&self) -> Vid
fn vid(&self) -> Vid
The unique ID of the vertex this VertexInfo
describes.
sourcefn coerced_to_type(&self) -> Option<&Arc<str>>
fn coerced_to_type(&self) -> Option<&Arc<str>>
The type coercion (... on SomeType
) applied by the query at this vertex, if any.
sourcefn required_properties(&self) -> Box<dyn Iterator<Item = RequiredProperty> + '_>
fn required_properties(&self) -> Box<dyn Iterator<Item = RequiredProperty> + '_>
Return all properties required for the current vertex, including: output, filtered, and tagged properties. It’s guaranteed that each property will only show once in the iterator, so even if a property has been used as a filter and output, it will only show once.
There is no guaranteed order.
This can be especially useful for adapters doing network calls. For example, if the adapter is using a relational database, it can retrieve the name of all properties and only request those columns from the table.
sourcefn statically_required_property(
&self,
name: &str
) -> Option<CandidateValue<FieldValue>>
fn statically_required_property( &self, name: &str ) -> Option<CandidateValue<FieldValue>>
Check whether the query demands this vertex property to have specific values: a single value, or one of a set or range of values. The candidate values are known statically: up-front, without executing any of the query.
For example, filtering a property based on a query variable (e.g.
@filter(op: "=", value: ["$expected"])
) means the filtered property will
need to match the value of the expected
query variable. This variable’s value is known
up-front at the beginning of query execution, so the filtered property has
a statically-required value.
In contrast, filters relying the value of a @tag
do not produce
statically-required values, since the @tag
value must be computed at runtime.
For this case, see the VertexInfo::dynamically_required_property()
method.
sourcefn dynamically_required_property(
&self,
name: &str
) -> Option<DynamicallyResolvedValue<'_>>
fn dynamically_required_property( &self, name: &str ) -> Option<DynamicallyResolvedValue<'_>>
Check whether the query demands this vertex property to have specific values: a single value, or one of a set or range of values. The candidate values are only known dynamically i.e. require some of the query to have already been executed at the point when this method is called.
For example, filtering a property with @filter(op: "=", value: ["%expected"])
means the property must have a value equal to the value of an earlier property
whose value is tagged like @tag(name: "expected")
. If the vertex containing
the tagged property has already been resolved in this query, this method will offer
to produce candidate values based on that tag’s value.
If only static information and no dynamic information is known about a property’s value,
this method will return None
in order to avoid unnecessary cloning.
The VertexInfo::statically_required_property()
method can be used to retrieve
the statically-known information about the property’s value.
If both static and dynamic information is known about a property’s value, all information will be merged automatically and presented via the output of this method.
sourcefn first_mandatory_edge(&self, name: &str) -> Option<EdgeInfo>
fn first_mandatory_edge(&self, name: &str) -> Option<EdgeInfo>
Returns info for the first not-yet-resolved edge by the given name that is mandatory: this vertex must contain the edge, or its result set will be discarded.
Edges marked @optional
, @fold
, or @recurse
are not mandatory:
@optional
edges that don’t exist producenull
outputs.@fold
edges that don’t exist produce empty aggregations.@recurse
always starts at depth 0 (i.e. returning the current vertex), so the edge is not required to exist.
sourcefn first_edge(&self, name: &str) -> Option<EdgeInfo>
fn first_edge(&self, name: &str) -> Option<EdgeInfo>
Returns info for the first not-yet-resolved edge by the given name.
Just a convenience wrapper over VertexInfo::edges_with_name()
.
sourcefn edges_with_name<'a>(
&'a self,
name: &'a str
) -> Box<dyn Iterator<Item = EdgeInfo> + 'a>
fn edges_with_name<'a>( &'a self, name: &'a str ) -> Box<dyn Iterator<Item = EdgeInfo> + 'a>
Returns an iterator of all not-yet-resolved edges by that name originating from this vertex.
This is the building block of VertexInfo::first_edge()
.
When possible, prefer using that method as it will lead to more readable code.
sourcefn mandatory_edges_with_name<'a>(
&'a self,
name: &'a str
) -> Box<dyn Iterator<Item = EdgeInfo> + 'a>
fn mandatory_edges_with_name<'a>( &'a self, name: &'a str ) -> Box<dyn Iterator<Item = EdgeInfo> + 'a>
Returns an iterator of all not-yet-resolved edges by that name that are mandatory: this vertex must contain the edge, or its result set will be discarded.
This is the building block of VertexInfo::first_mandatory_edge()
.
When possible, prefer using that method as it will lead to more readable code.