unify-mercurius
TypeScript icon, indicating that this package has built-in type declarations

1.3.416 • Public • Published

Test Coverage Maintainability npm npm Snyk Vulnerabilities for npm package NPM

Unify Mercurius

A Mercurius plugin wrapping unify-errors to handle REST errors. Old Owner: @flexper

Install

npm i unify-mercurius
# Or
yarn add unify-mercurius
# Or
pnpm add unify-mercurius

Use

'use strict'

const Fastify = require('fastify')
const mercurius = require('mercurius')
const { unifyMercuriusErrorFormatter } = require('unify-mercurius')

const app = Fastify()

const schema = `
  type Query {
    add(x: Int, y: Int): Int
  }
`

const resolvers = {
  Query: {
    add: async (_, { x, y }) => x + y
  }
}

app.register(mercurius, {
  schema,
  resolvers,
  errorFormatter: unifyMercuriusErrorFormatter()
})

app.get('/', async function (req, reply) {
  const query = '{ add(x: 2, y: 2) }'
  return reply.graphql(query)
})

app.listen(3000)

Plugin options

name default description
disableDetails false If true will remove the originalError key from the error response
disableLog false Disable logging on error

Tests

To execute jest tests (all errors, type integrity test)

pnpm test

Maintain

This package use TSdx. Please check documentation to update this package.

Readme

Keywords

none

Package Sidebar

Install

npm i unify-mercurius

Weekly Downloads

216

Version

1.3.416

License

MIT

Unpacked Size

43.9 kB

Total Files

12

Last publish

Collaborators

  • qlaffont