From a96d1005f0737e7dcec127c4396e408f31deb2ec Mon Sep 17 00:00:00 2001 From: Artjoms Iskovs Date: Tue, 28 Dec 2021 15:50:45 +0000 Subject: [PATCH] Replace `abort()` with `raise SanicException` This is for compatibility with newly-released Sanic 21.12 which removed the deprecated `abort()` in https://github.com/sanic-org/sanic/pull/2306. Before that, it was a simple wrapper around `raise SanicException` (https://github.com/sanic-org/sanic/blob/523db190a732177eda5a641768667173ba2e2452/sanic/exceptions.py#L262-L265), so this change makes it explicit and removes the dependency on `abort()`. --- strawberry/sanic/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/strawberry/sanic/views.py b/strawberry/sanic/views.py index 63f0bd37b2..182f49b846 100644 --- a/strawberry/sanic/views.py +++ b/strawberry/sanic/views.py @@ -1,7 +1,7 @@ import json from typing import Any -from sanic.exceptions import ServerError, abort +from sanic.exceptions import SanicException, ServerError from sanic.request import Request from sanic.response import HTTPResponse, html from sanic.views import HTTPMethodView @@ -57,7 +57,7 @@ def process_result(self, result: ExecutionResult) -> GraphQLHTTPResponse: async def get(self, request: Request) -> HTTPResponse: if not self.graphiql: - abort(404) + raise SanicException(status_code=404) template = render_graphiql_page() return self.render_template(template=template) @@ -101,5 +101,5 @@ def parse_body(self, request: Request) -> dict: try: return replace_placeholders_with_files(operations, files_map, files) except KeyError: - abort(400, "File(s) missing in form data") + raise SanicException(status_code=400, message="File(s) missing in form data") return request.json