1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use juniper::FieldError;
use std::marker::PhantomData;

pub mod internal;
pub mod macro_helpers;

#[derive(Debug, Clone)]
pub struct HasOne<T, S, M> {
    sql_type: PhantomData<T>,
    schema: PhantomData<S>,
    model: PhantomData<M>,
}

#[derive(Debug, Clone)]
pub struct HasMany<S, F, M> {
    schema: PhantomData<S>,
    forign_key: PhantomData<F>,
    model: PhantomData<M>,
}

pub trait Context {
    type DB;
    type Connection;

    fn get_connection<'a>(&'a self) -> &'a Self::Connection;
}

pub trait QueryModifier<T, R, C: Context> {
    fn modify_query(query: T, context: &C) -> Result<R, FieldError>;
}