pub fn resolve_typename<'a, Vertex: Typename + Debug + Clone + 'a, V: AsVertex<Vertex> + 'a>(
    contexts: ContextIterator<'a, V>,
    schema: &Schema,
    type_name: &str
) -> ContextOutcomeIterator<'a, V, FieldValue>
Expand description

Resolver for the __typename property that optimizes resolution based on the schema.

Example:

// Inside your `Adapter` or `BasicAdapter` implementation.
fn resolve_property(
    // &mut self,
    contexts: ContextIterator<'vertex, Vertex>,
    type_name: &str,
    property_name: &str,
    // < other args >
) -> ContextOutcomeIterator<'vertex, Vertex, FieldValue> {
    if property_name == "__typename" {
        return resolve_typename(contexts, &SCHEMA, type_name);
    }

    // Resolve all other properties here.
}

This resolver uses the schema to check whether the type named by type_name has any subtypes. If so, then each vertex must be resolved dynamically since it may be any of those subtypes. Otherwise, the type must be exactly the value given in type_name, and we can take a faster path.