1.0.0-beta-1 • Published 3 years ago

@nbn23/plugin-http-error v1.0.0-beta-1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

NBN23 HTTP error plugin

HTTPErrorPlugin is a GraphQL plugin that handles HTTP codes on a GraphQL response rather than return always 200. This plugin handles the error codes through the HTTPError class.

Getting Started

Install HTTPErrorPlugin using npm.

npm install --save @nbn23/plugin-http-error

Note: CloudTasks assumes a TypeScript environment

Usage

import { HTTPErrorPlugin } from "@nbn23/plugin-http-error";

const server = new ApolloServer({
  ...
  plugins: [new HTTPErrorPlugin()]
});

throw new HTTPError(404, "Bad request.");