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>

source

pub fn new(schema_to_query: &'a Schema) -> Self

Make an adapter for querying the given Trustfall schema.

source

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>

§

type Vertex = SchemaVertex<'a>

The type of vertices in the dataset this adapter queries. Unless your intended vertex type is cheap to clone, consider wrapping it an Rc or Arc to make cloning it cheaper since that’s a fairly common operation when queries are evaluated.
source§

fn resolve_starting_vertices( &self, edge_name: &Arc<str>, _parameters: &EdgeParameters, resolve_info: &ResolveInfo ) -> VertexIterator<'a, Self::Vertex>

Produce an iterator of vertices for the specified starting edge. Read more
source§

fn resolve_property<V: AsVertex<Self::Vertex> + 'a>( &self, contexts: ContextIterator<'a, V>, type_name: &Arc<str>, property_name: &Arc<str>, _resolve_info: &ResolveInfo ) -> ContextOutcomeIterator<'a, V, FieldValue>

Resolve a property required by the query that’s being evaluated. Read more
source§

fn resolve_neighbors<V: AsVertex<Self::Vertex> + 'a>( &self, contexts: ContextIterator<'a, V>, type_name: &Arc<str>, edge_name: &Arc<str>, _parameters: &EdgeParameters, resolve_info: &ResolveEdgeInfo ) -> ContextOutcomeIterator<'a, V, VertexIterator<'a, Self::Vertex>>

Resolve the neighboring vertices across an edge. Read more
source§

fn resolve_coercion<V: AsVertex<Self::Vertex> + 'a>( &self, contexts: ContextIterator<'a, V>, type_name: &Arc<str>, coerce_to_type: &Arc<str>, resolve_info: &ResolveInfo ) -> ContextOutcomeIterator<'a, V, bool>

Attempt to coerce vertices to a subtype, as required by the query that’s being evaluated. Read more
source§

impl<'a> Debug for SchemaAdapter<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.