Skip to content

feat(factory): add 99designs/gqlgen contrib with a boost-error ErrorPresenter (GraphQL = 4th transport) #44

Open

Description

@jpfaria

Problem

boost maps its typed-error catalog to a transport code automatically on three edges:

  • Echo error_handler → HTTP status
  • gRPC server → codes.Code
  • function / CloudEvents → deadletter / status

GraphQL is the gap. With 99designs/gqlgen, a resolver error is caught by gqlgen, run through its ErrorPresenter, and written as HTTP 200 with the error inside the errors[] array. The Echo error_handler never sees it, so the public extensions.code is not derived from the boost catalog — every service hand-rolls its own presenter.

Proposal

Ship a factory/contrib/99designs/gqlgen/v0 package providing a ready boost-aware ErrorPresenter (and optionally a thin server constructor mirroring the other factories) that:

  1. Walks the stdlib error chain (boost typed errors now implement Unwrap()).
  2. Maps the boost catalog → a stable extensions.code via the same classification the other transports use:
    • once the error registry (Classify / Kind, branch feat/error-registry) lands → a Kind → code table, sibling to restresponse.HTTPStatusFor and the gRPC Kind → codes.Code table;
    • meanwhile → the Is* catalog: IsNotFound→NOT_FOUND, IsServiceUnavailable→UPSTREAM_UNAVAILABLE, IsForbidden/IsConflict→FORBIDDEN, IsBadRequest/IsNotValid→BAD_USER_INPUT, default INTERNAL_SERVER_ERROR.
  3. Never leaks internals for Internal / ServiceUnavailable (safe message).
  4. Honors IgnoreOf (registry) the same way the other edges do.

This makes GraphQL the 4th transport over the single boost error catalog — srv.SetErrorPresenter(gqlgenfact.ErrorPresenter) and resolvers keep returning boost typed errors.

Notes / open questions

  • Dependency surface: adds github.com/99designs/gqlgen + github.com/vektah/gqlparser/v2. Suggest isolating it as its own contrib module (own go.mod) so boost core doesn't take the dep, consistent with the other factory/contrib/*.
  • The code-string set should be exported + overridable (each service maps to its own public GraphQL contract).
  • Reference pattern is already documented in the boost-model-errors skill → section "GraphQL transport — gqlgen ErrorPresenter".
  • Related: Err.Unwrap() (stdlib errors.Is/As transparency) already landed on main.

Acceptance

  • factory/contrib/99designs/gqlgen/v0 with ErrorPresenter (+ tests) mapping the boost catalog → extensions.code
  • Honors the error registry Classify / IgnoreOf once available
  • Exported, overridable code strings
  • Docs/skill (boost-model-errors and/or a new boost-factory-gqlgen) updated

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions