Skip to content

Latest commit

 

History

History
executable file
·
59 lines (40 loc) · 2.33 KB

File metadata and controls

executable file
·
59 lines (40 loc) · 2.33 KB

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