Open
Description
Right now my context has a lifetime
use juniper::Context as JuniperContext;
use postgres::transaction::Transaction;
pub struct Context<'a> {
pub tx: Transaction<'a>,
}
impl<'a> JuniperContext for Context<'a> {}
impl<'a> Context<'a> {
pub fn new(tx: Transaction<'a>) -> Context<'a> {
Context { tx: tx }
}
}
But when I try to specify the same lifetime in a resolver then it gives me this error,
error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
--> src/schema/query.rs:7:18
|
7 | graphql_object!(<'a> QueryRoot: Context<'a> as "Query" |&self| {
| ^^ unconstrained lifetime parameter
use models::user::User;
use schema::context::Context;
pub struct QueryRoot;
graphql_object!(<'a> QueryRoot: Context<'a> as "Query" |&self| {
field users(&executor) -> FieldResult<Vec<User>> {
Ok(vec![])
}
});