-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GraphQLContext derive #329
Comments
Actually, I think we could just deprecate the There is no real reason for it to be there. |
I guess the only reason for it's existence would be that you can't use a type as context in the macros that isn't intended to be used as a context. But that would produce compile time errors anyway once you actually construct the schema. |
Do we want to reserve the trait for future extensibility? If we remove the requirement and later need it for implementation specifics, it would be a breaking change. |
@LegNeato what sort of future extensibility are you thinking of? I imagine adding methods to the trait would also be breaking change. I'm also in favour of deprecating it. |
I don't see a reason to ever add methods on context. There is a consideration with futures support though: we will probably need a |
I'm not that familiar with futures, but why The app I'm working on has a context like this: pub struct Context {
db: DbCon,
// more things...
} Where pub struct DbCon(pub PooledConnection<ConnectionManager<PgConnection>>);
I could instead store the connection pool itself in the context. The pool is I also see that |
That's a necessary result from concurrency/parallelism. You could still use a single DB connection per query by wrapping it in But that would of course negate any benefit if most of your resolvers need the db. |
Makes sense. Seems to still be early days for async in Diesel. |
I think we could use a trait alias for this in the future for async. Having an empty trait doesn't make much sense to me. I will try to make a PR to remove it. |
@petoknm great that you want to help out, I would hold off on this for now though until I publish my async/await branch and we have a clearer picture of what will be needed. |
Cool, I didn't know that work on async support has already started. |
Is your feature request related to a problem? Please describe.
Contexts have some boilerplate, you have to implement
juniper::Context
which is usually an empty marker trait. The error message when you don't isn't obvious, see #327.Describe the solution you'd like
It might be good to have a
#[derive(GraphQLContext)
that does the boilerplate for you. It won't help the error message, but perhaps when people are copying and pasting or reading docs they will be less likely to miss it.The text was updated successfully, but these errors were encountered: