pub struct SchemaAdapter<'a> { /* private fields */ }
Expand description
A Trustfall adapter for querying Trustfall schemas.
The schema matching this adapter is in the adjacent
schema.graphql
file,
and is also available via the SchemaAdapter::schema_text()
function.
§Example
Create the adapter for querying a given schema like so:
let schema_text = include_str!("./schema.graphql");
let schema = Schema::parse(schema_text).expect("not a valid schema");
// Create an adapter that queries
// the schema in the local `schema.graphql` file.
let adapter = SchemaAdapter::new(&schema);
// Run queries using the adapter, etc.
Then you can query the contents of that schema. For example, the following query asks for all vertex properties and their types:
query {
VertexType {
name @output
property {
property_name: name @output
property_type: type @output
}
}
}
Implementations§
Source§impl<'a> SchemaAdapter<'a>
impl<'a> SchemaAdapter<'a>
Sourcepub fn new(schema_to_query: &'a Schema) -> SchemaAdapter<'a>
pub fn new(schema_to_query: &'a Schema) -> SchemaAdapter<'a>
Make an adapter for querying the given Trustfall schema.
Sourcepub fn schema_text() -> &'static str
pub fn schema_text() -> &'static str
A schema that describes Trustfall schemas.
Queries on this adapter must conform to this schema.
Trait Implementations§
Source§impl<'a> Adapter<'a> for SchemaAdapter<'a>
impl<'a> Adapter<'a> for SchemaAdapter<'a>
Source§fn resolve_starting_vertices(
&self,
edge_name: &Arc<str>,
_parameters: &EdgeParameters,
resolve_info: &ResolveInfo,
) -> Box<dyn Iterator<Item = <SchemaAdapter<'a> as Adapter<'a>>::Vertex> + 'a>
fn resolve_starting_vertices( &self, edge_name: &Arc<str>, _parameters: &EdgeParameters, resolve_info: &ResolveInfo, ) -> Box<dyn Iterator<Item = <SchemaAdapter<'a> as Adapter<'a>>::Vertex> + 'a>
Produce an iterator of vertices for the specified starting edge. Read more
Source§fn resolve_property<V>(
&self,
contexts: Box<dyn Iterator<Item = DataContext<V>> + 'a>,
type_name: &Arc<str>,
property_name: &Arc<str>,
_resolve_info: &ResolveInfo,
) -> Box<dyn Iterator<Item = (DataContext<V>, FieldValue)> + 'a>
fn resolve_property<V>( &self, contexts: Box<dyn Iterator<Item = DataContext<V>> + 'a>, type_name: &Arc<str>, property_name: &Arc<str>, _resolve_info: &ResolveInfo, ) -> Box<dyn Iterator<Item = (DataContext<V>, FieldValue)> + 'a>
Resolve a property required by the query that’s being evaluated. Read more
Source§fn resolve_neighbors<V>(
&self,
contexts: Box<dyn Iterator<Item = DataContext<V>> + 'a>,
type_name: &Arc<str>,
edge_name: &Arc<str>,
_parameters: &EdgeParameters,
resolve_info: &ResolveEdgeInfo,
) -> Box<dyn Iterator<Item = (DataContext<V>, Box<dyn Iterator<Item = <SchemaAdapter<'a> as Adapter<'a>>::Vertex> + 'a>)> + 'a>
fn resolve_neighbors<V>( &self, contexts: Box<dyn Iterator<Item = DataContext<V>> + 'a>, type_name: &Arc<str>, edge_name: &Arc<str>, _parameters: &EdgeParameters, resolve_info: &ResolveEdgeInfo, ) -> Box<dyn Iterator<Item = (DataContext<V>, Box<dyn Iterator<Item = <SchemaAdapter<'a> as Adapter<'a>>::Vertex> + 'a>)> + 'a>
Resolve the neighboring vertices across an edge. Read more
Source§fn resolve_coercion<V>(
&self,
contexts: Box<dyn Iterator<Item = DataContext<V>> + 'a>,
type_name: &Arc<str>,
coerce_to_type: &Arc<str>,
resolve_info: &ResolveInfo,
) -> Box<dyn Iterator<Item = (DataContext<V>, bool)> + 'a>
fn resolve_coercion<V>( &self, contexts: Box<dyn Iterator<Item = DataContext<V>> + 'a>, type_name: &Arc<str>, coerce_to_type: &Arc<str>, resolve_info: &ResolveInfo, ) -> Box<dyn Iterator<Item = (DataContext<V>, bool)> + 'a>
Attempt to coerce vertices to a subtype, as required by the query that’s being evaluated. Read more
Auto Trait Implementations§
impl<'a> Freeze for SchemaAdapter<'a>
impl<'a> RefUnwindSafe for SchemaAdapter<'a>
impl<'a> Send for SchemaAdapter<'a>
impl<'a> Sync for SchemaAdapter<'a>
impl<'a> Unpin for SchemaAdapter<'a>
impl<'a> UnwindSafe for SchemaAdapter<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more