graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

Warn about a DbContext accessed via DI without Serial execution

Open tobias-tengler opened this issue 2 years ago • 3 comments

Is your feature request related to a problem?

I just watched a video tutorial on Hot Chocolate + Entity Framework and it was using the scoped DbContext and injected it using the ServiceAttribute. As we all know this could lead to exceptions, if two fields inside of a single query do this. But to newcomers this seems like the correct thing to do, by their understanding of the ServiceAttribute and a scoped DbContext. Without reading the integration documentation, they are unaware of the potential issues. So code like this could most likely end up in a production environment (and likely already has often), until one day exceptions appear out of nowhere. It would be great if Hot Chocolate could preemptively guide us to the correct solution.

The solution you'd like

I really like the validation of the middleware order that was added in v12 and I think the DbContext integration could benefit from the same thing. A resolver accessing a DbContext through dependency injection, without being flagged for serial execution or being part of a resolver-scoped service scope, should trigger a warning similar to the validation of middleware. This warning could instruct people to use the Serial functionality or link to our Entity Framework integration documentation.

Product

Hot Chocolate

tobias-tengler avatar Nov 13 '21 15:11 tobias-tengler

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 04 '22 12:05 stale[bot]

Should still be resolved in any way, I think?

KreativJos avatar May 09 '22 15:05 KreativJos

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 06 '22 16:09 stale[bot]