Skip to content
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

When raise exception I got graphql error #982

Closed
Bunlong opened this issue Jun 24, 2020 · 2 comments
Closed

When raise exception I got graphql error #982

Bunlong opened this issue Jun 24, 2020 · 2 comments

Comments

@Bunlong
Copy link

Bunlong commented Jun 24, 2020

I just move from using responder library to starlette. I got the graphql error when I raise exception.

Server:

app = Starlette(debug=True, routes=[
    Route('/', show_version),
    Route('/healthz', check_health),
    Route('/graphql', GraphQLApp(schema=schema)),
])

if __name__ == '__main__':
    uvicorn.run(app, host='0.0.0.0', port=9090)

Schema:

...

raise Exception('Something wrong')

...

Error:

Screenshot from 2020-06-24 13-40-48

What I expect is it return error message Something wrong with the http status 200 instead of error above. Thanks!

@JayH5 JayH5 added the graphql label Sep 11, 2020
@chrisbrake
Copy link

chrisbrake commented Jan 31, 2021

I've run into this issue as well.

This appears to be the code responsible.

status_code = (
status.HTTP_400_BAD_REQUEST if result.errors else status.HTTP_200_OK
)
return JSONResponse(
response_data, status_code=status_code, background=background
)

Looks to be more or less original to the implementation here, it came along with this commit: 315a21b.

Maintainers, would an acceptable solution be to add an option to specify the status code to use when errors exist?
With the default being the current behavior of course.

@JayH5
Copy link
Member

JayH5 commented Feb 5, 2021

Thank you for filing this issue. We have decided to deprecate GraphQL support within Starlette itself so I am going to close this issue. See #619.

@JayH5 JayH5 closed this as completed Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants