Trait GraphqlNodeForModel

Source
pub trait GraphqlNodeForModel: Sized {
    type Model: Clone;
    type Id: 'static + Hash + Eq;
    type Context;
    type Error;

    // Required method
    fn new_from_model(model: &Self::Model) -> Self;

    // Provided method
    fn from_db_models(models: &[Self::Model]) -> Vec<Self> { ... }
}
Expand description

A GraphQL type backed by a model object.

You shouldn’t need to implement this trait yourself even when customizing eager loading.

Required Associated Types§

Source

type Model: Clone

The model type.

Source

type Id: 'static + Hash + Eq

The id type the model uses.

Source

type Context

Your Juniper context type.

This will typically contain a database connection or a connection to some external API.

Source

type Error

The error type.

Required Methods§

Source

fn new_from_model(model: &Self::Model) -> Self

Create a new GraphQL type from a model.

Provided Methods§

Source

fn from_db_models(models: &[Self::Model]) -> Vec<Self>

Create a list of GraphQL types from a list of models.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§