fastapi-utils icon indicating copy to clipboard operation
fastapi-utils copied to clipboard

[FEATURE] Dependency injection doesn't work in @repeat_every functions

Open alexking opened this issue 4 years ago • 0 comments

Is your feature request related to a problem? Please describe. There is no way to include dependencies in a @repeat_every function (aka service = Depends(get_service)). This means if you've built dependency functions for use with path operations (@app.get decorated functions), you'll have to resolve those (at possibly multiple levels) by hand.

Describe the solution you'd like Ideally, we'd just add support for this. However FastAPI doesn't have a way to resolve something from outside a path operation, and solve_dependencies seems to require a Request of some kind to work. There was some discussion of trying to make that accessible to third party libraries here.

Describe alternatives you've considered Assuming that there isn't a simple way to implement this, it might be good to add a note in the documentation just mentioning that @repeat_every does not support Depends, until that becomes available.

alexking avatar Sep 18 '20 16:09 alexking