@webundsoehne/nestjs-util-graphql
TypeScript icon, indicating that this package has built-in type declarations

3.0.12 • Public • Published

Web und Söhne - Logo

Web & Söhne is Austria's leading expert in programming and implementing complex and large web projects.

@webundsoehne/nestjs-util-graphql

Version Downloads/week Dependencies semantic-release

Description

This is a collection of useful modules for creating a NestJS project. Mostly all of these modules are used by the in-house boilerplate of Web & Söhne.

Modules

Filters

GraphQL Error Parser

Since nest.js lets GraphQL handle its errors in its own way, graphqlErrorParser is just a function instead of a filter. This will format the errors in the same way of the HTTP errors, so you can also throw HTTP_STATUS errors instead of plain GraphQLError for more distinction and using the status code directly in the frontend. It will also add the GraphQL error field of which field this error is coming from.

Usage

Just add the error parser to the GraphQL Module itself.

import { GraphQLModule } from '@nestjs/graphql'
import { GraphQLErrorParser } from '@webundsoehne/nestjs-util-graphql'
import { Module } from '@nestjs/common'

@Module({
  imports: [
    GraphQLModule.forRoot({
      formatError: GraphQLErrorParser
    })
  ]
})
export class ServerModule {}

Stay in touch

Readme

Keywords

Package Sidebar

Install

npm i @webundsoehne/nestjs-util-graphql

Weekly Downloads

21

Version

3.0.12

License

ISC

Unpacked Size

12.2 kB

Total Files

13

Last publish

Collaborators

  • ws-admin
  • dabls