1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::graphql_type::WundergraphGraphqlMapper;
use crate::scalar::WundergraphScalarValue;
use juniper::{meta, Registry};
use std::marker::PhantomData;

/// Type used to indicate that a given field references multiple other entities
/// by a given id
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct HasMany<T, FK>(Vec<T>, PhantomData<FK>);

impl<T, DB, Ctx, FK> WundergraphGraphqlMapper<DB, Ctx> for HasMany<T, FK>
where
    T: WundergraphGraphqlMapper<DB, Ctx>,
{
    type GraphQLType = Vec<T::GraphQLType>;

    fn register_arguments<'r>(
        registry: &mut Registry<'r, WundergraphScalarValue>,
        field: meta::Field<'r, WundergraphScalarValue>,
    ) -> meta::Field<'r, WundergraphScalarValue> {
        T::register_arguments(registry, field)
    }
}