Platform GraphQL Fastify
The GraphQLFastifyParser parser for the OgmaInterceptor. This plugin class parses GraphQL request and response object to be able to successfully log the data about the request. For more information, check out the @ogma/nestjs-module documentation.
Installation
Nothing special, standard npm i @ogma/platform-graphql-fastify or yarn add @ogma/platform-graphql-fastify
Usage
This plugin is to be used in the OgmaInterceptorOptions portion of the OgmaModule during forRoot or forRootAsync registration. It can be used like so:
@Module({
imports: [OgmaModule.forRoot({})],
providers: [GraphQLFastifyParser]
})
export class AppModule {}
Because the interceptor needs access to the request and response objects, when configuring the GraphqlModule from Nest, you need to add the request and reply to the GraphQL context. to do this, while configuring the GraphqlModule, set the context property as such:
GraphqlModule.forRoot({
context: ({ request, reply }) => ({ request, reply })
});