graphql-python / graphql-server

This is the core package for using GraphQL in a custom server easily
MIT License
120 stars 72 forks source link

request.get_data from graphql_server.quart.GraphQLView uses incorrect api #94

Closed Choongkyu closed 1 year ago

Choongkyu commented 2 years ago

hello. I noticed that when using GraphQLView as follows,

app.add_url_rule(
    '/graphql',
    view_func=GraphQLView.as_view(
        'graphql',
        schema=schema,
        graphiql=True
    )
)

I get the following error:

[2022-09-05 22:37:21,086] ERROR in app: Exception on request POST /graphql
Traceback (most recent call last):
  File "/Users/user/code/python-gql/.venv/lib/python3.9/site-packages/quart/app.py", line 1629, in handle_request
    return await self.full_dispatch_request(request_context)
  File "/Users/user/code/python-gql/.venv/lib/python3.9/site-packages/quart/app.py", line 1654, in full_dispatch_request
    result = await self.handle_user_exception(error)
  File "/Users/user/code/python-gql/.venv/lib/python3.9/site-packages/quart/app.py", line 1099, in handle_user_exception
    raise error
  File "/Users/user/code/python-gql/.venv/lib/python3.9/site-packages/quart/app.py", line 1652, in full_dispatch_request
    result = await self.dispatch_request(request_context)
  File "/Users/user/code/python-gql/.venv/lib/python3.9/site-packages/quart/app.py", line 1697, in dispatch_request
    return await self.ensure_async(handler)(**request_.view_args)
  File "/Users/user/code/python-gql/.venv/lib/python3.9/site-packages/quart/views.py", line 62, in view
    return await current_app.ensure_async(self.dispatch_request)(**kwargs)
  File "/Users/user/code/python-gql/.venv/lib/python3.9/site-packages/graphql_server/quart/graphqlview.py", line 91, in dispatch_request
    data = await self.parse_body()
  File "/Users/user/code/python-gql/.venv/lib/python3.9/site-packages/graphql_server/quart/graphqlview.py", line 173, in parse_body
    refined_data = await request.get_data(raw=False)
TypeError: get_data() got an unexpected keyword argument 'raw'

According to https://pgjones.gitlab.io/quart/reference/source/quart.html, get_data's signature is as follows:

async get_data(cache: bool, as_text: Literal[False], parse_form_data: bool) → bytes
async get_data(cache: bool, as_text: Literal[True], parse_form_data: bool) → str
async get_data(cache: bool = True, as_text: bool = False, parse_form_data: bool = False) → AnyStr