Request object isn't passed as argument
See original GitHub issueThanks for this package. I have created graphql app using template but getting below error. It seems fastapi doesn’t pass request object.
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 184, in run_asgi
result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
return await self.app(scope, receive, send)
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/applications.py", line 261, in __call__
await super().__call__(scope, receive, send)
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py", line 146, in __call__
await self.app(scope, receive, send)
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/starlette/exceptions.py", line 58, in __call__
await self.app(scope, receive, send)
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
raise e
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
await self.app(scope, receive, send)
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 656, in __call__
await route.handle(scope, receive, send)
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 315, in handle
await self.app(scope, receive, send)
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 77, in app
await func(session)
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 264, in app
solved_result = await solve_dependencies(
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 498, in solve_dependencies
solved_result = await solve_dependencies(
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 498, in solve_dependencies
solved_result = await solve_dependencies(
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 498, in solve_dependencies
solved_result = await solve_dependencies(
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 523, in solve_dependencies
solved = await solve_generator(
File "/Users/test/Library/Caches/pypoetry/virtualenvs/fastapi-graphql-practice-1UuEp-7G-py3.10/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 443, in solve_generator
cm = asynccontextmanager(call)(**sub_values)
File "/Users/test/.pyenv/versions/3.10.2/lib/python3.10/contextlib.py", line 314, in helper
return _AsyncGeneratorContextManager(func, args, kwds)
File "/Users/test/.pyenv/versions/3.10.2/lib/python3.10/contextlib.py", line 103, in __init__
self.gen = func(*args, **kwds)
TypeError: get_db_session() missing 1 required positional argument: 'request'
INFO: connection open
INFO: connection closed
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:16 (10 by maintainers)
Top Results From Across the Web
node.js - If request object is not being used should i remove it ...
If you were to remove 'req' as the first parameter, the request object would still be passed as the first parameter.
Read more >Request() - Web APIs - MDN Web Docs
The Request() constructor creates a new Request object.
Read more >Request & Response Objects - 4.x - CakePHP Cookbook
// Passed arguments $passedArgs = $this->request->getParam('pass');. Will all provide you access to the passed arguments. There are several important/useful ...
Read more >Request Object | Branch CMS Documentation
The request object allows you to submit a POST or GET request to an URL. ... If this was a GET request then...
Read more >Using the Request Directly - FastAPI
It would also mean that if you get data from the Request object directly (for ... being the Request FastAPI will know to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Until this is issue is solved, you can get rid of the error messages by changing the dependency slightly:
https://github.com/s3rius/FastAPI-template/blob/98f07cd0f9cc697ce5e64721c0a6505860729aba/fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_sa/dependencies.py#L7-L20
Hi there. I found no issues for this problem in
strawberry-graphql
repository. So I created one.