techmatters / terraso-backend

A Django project that powers the backend of Terraso platform.
GNU Affero General Public License v3.0
21 stars 4 forks source link

Standardize LandPKS GraphQL API error responses #1264

Open tm-ruxandra opened 6 months ago

tm-ruxandra commented 6 months ago

Create standard response formats for GraphQL API error handling and apply them to the LandPKS Terraso backend.

Description

Currently, error handling and response code behavior is ad-hoc and not standard. For example, a few different error modes currently in use:

        if not target_membership:
            cls.not_allowed(
                MutationTypes.DELETE, msg="Cannot delete a user membership that does not exist"
            )
        if not user.has_perm(SiteNote.get_perm("delete"), site_note):
            cls.not_allowed()
        return SiteTransferMutation(
            bad_permissions=bad_permissions,
        )

Research best-practices for GraphQL error handling and find a strategy to apply to the LandPKS backend. Add appropriate unit/integration tests and update the frontend as needed.

shrouxm commented 2 weeks ago

related to #510