Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qlaffont/unify-mercurius
Mercurius error formater with unify-errors
https://github.com/qlaffont/unify-mercurius
fastify graphql mercurius typescript unify-errors
Last synced: about 1 month ago
JSON representation
Mercurius error formater with unify-errors
- Host: GitHub
- URL: https://github.com/qlaffont/unify-mercurius
- Owner: qlaffont
- License: mit
- Created: 2022-04-21T12:44:21.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T17:36:51.000Z (about 2 months ago)
- Last Synced: 2024-10-29T18:57:37.506Z (about 2 months ago)
- Topics: fastify, graphql, mercurius, typescript, unify-errors
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/unify-mercurius
- Size: 2.01 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Test Coverage](https://api.codeclimate.com/v1/badges/d28d1f8e89ae26ed6055/test_coverage)](https://codeclimate.com/github/qlaffont/unify-mercurius/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/d28d1f8e89ae26ed6055/maintainability)](https://codeclimate.com/github/qlaffont/unify-mercurius/maintainability)
![npm](https://img.shields.io/npm/v/unify-mercurius) ![npm](https://img.shields.io/npm/dm/unify-mercurius) ![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/unify-mercurius) ![NPM](https://img.shields.io/npm/l/unify-mercurius)
# Unify MercuriusA Mercurius plugin wrapping [unify-errors](https://github.com/qlaffont/unify-errors) to handle REST errors. Old Owner: [@flexper](https://github.com/flexper)
## Install
```sh
npm i unify-mercurius
# Or
yarn add unify-mercurius
# Or
pnpm add unify-mercurius
```## Use
```javascript
'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)
```bash
pnpm test
```## Maintain
This package use [TSdx](https://github.com/jaredpalmer/tsdx). Please check documentation to update this package.