@webundsoehne/nestjs-util-graphql
v3.0.14
Published
NestJS skeleton util library for graphql applications.
Downloads
507
Readme
@webundsoehne/nestjs-util-graphql
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
- Author: Backend Team
- Website: Web & Söhne