sofa

sofa

  • Documentation
  • Github

›API

Introduction

  • Getting Started

Essentials

  • Queries
  • Mutations
  • Subscription

Recipes

  • OpenAPI (Swagger)

API

  • Nested data and Models
  • Using context
  • Using objects instead of IDs
  • Custom execute phase
  • Error Handling
  • Customize endpoint's HTTP Method

Error Handling

By default, Sofa returns a response that includes JSON representation of thrown error object from GraphQL with HTTP status code 500. But, you can enhance error handler by adding your errorHandler function.

api.use(
  '/api',
  sofa({
    schema,
    errorHandler(res, errors) {
      logErrors(errors);
      res.code(500);
      res.json(formatError(errors[0]));
    },
  })
);
Last updated on 3/9/2021 by renovate[bot]
← Custom execute phaseCustomize endpoint's HTTP Method →
sofa
Twitter·Medium·Github
Copyright © 2021 The Guild