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

Implement Exception Handling by Graphene Middleware #3213

Open
jopemachine opened this issue Dec 6, 2024 · 0 comments
Open

Implement Exception Handling by Graphene Middleware #3213

jopemachine opened this issue Dec 6, 2024 · 0 comments
Labels
type:refactor Refactor codes or add tests.

Comments

@jopemachine
Copy link
Member

jopemachine commented Dec 6, 2024

Main idea

In the current code, each mutation requires manually injecting ok and msg in the form of cls(ok="...", msg="...") every time.
This approach is prone to mistakes, and since it involves code related to the API interface, mistakes can be difficult to roll back.

We can refactor it to simply throw an error when an error occurs, allowing the middleware to handle it instead.
It seems this middleware could be added at the following location.

middleware=[
GQLLoggingMiddleware(),
GQLMutationUnfrozenRequiredMiddleware(),
GQLMutationPrivilegeCheckMiddleware(),
],

@jopemachine jopemachine changed the title Implementation of Exception Handling in Graphene Middleware Implementat Exception Handling in Graphene Middleware Dec 6, 2024
@jopemachine jopemachine changed the title Implementat Exception Handling in Graphene Middleware Implement Exception Handling by Graphene Middleware Dec 6, 2024
@jopemachine jopemachine added the type:refactor Refactor codes or add tests. label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:refactor Refactor codes or add tests.
Projects
None yet
Development

No branches or pull requests

1 participant