Closed
Description
Hi there!
I'm currently writing a Paginated<T>
type for paginated responses, where T
is a value that can be handled by GraphQL.
I struggle at writing this structure, here is what I have currently:
struct Paginated<T> {
items: Vec<T>
}
#[graphql_object]
impl<T> Paginated<T> {
pub fn items(&self) -> &[T] {
self.items.as_slice()
}
}
This fails because T
is not a GraphQLValue
. Seems logical, so I added a where T: GraphQLValue<DefaultScalarValue>
constraint to my impl
. But now it asks me to also implement IsOutputType
, GraphQLType
, GraphQLValueAsync
, ensure that <T as GraphQLValue>::Context: juniper::Context
, and so on.
This is a lot of constraints (especially the GraphQLValueAsync
part) so is there a simpler way to constraint T
?
Thanks in advance for your help!