@@ -117,8 +117,8 @@ Next we need an adaptor to convert a generic PostGraphile route handler into a
117117handler that's suitable for your given server framework. We provide the
118118following out of the box:
119119
120- - ` PostGraphileResponseNode ` - for Node, Express, Connect, Restify, and Fastify
121- v2 (NOT v3)
120+ - ` PostGraphileResponseNode ` - for Node, Express, Connect, Nest, Restify, and
121+ Fastify v2 (NOT v3)
122122- ` PostGraphileResponseKoa ` - for Koa
123123- ` PostGraphileResponseFastify3 ` - for Fastify v3
124124
@@ -218,6 +218,28 @@ if (middleware.options.watchPg) {
218218}
219219```
220220
221+ For Nest, this might look something like:
222+
223+ ``` js
224+ import { Controller , Get , Post , Req , Next , Res } from ' @nestjs/common' ;
225+ import { Request , Response } from ' express' ;
226+ import { PostGraphileResponseNode } from ' postgraphile' ;
227+ import { middleware } from ' ./postgraphile.middleware' ;
228+
229+ @Controller (' /' )
230+ export class PostGraphileController {
231+ @Get (middleware .graphiqlRoute )
232+ graphiql (@Req () request: Request, @Res () response: Response, @Next () next) {
233+ middleware .graphiqlRouteHandler (new PostGraphileResponseNode (request, response, next));
234+ }
235+
236+ @Post (middleware .graphqlRoute )
237+ graphql (@Req () request: Request, @Res () response: Response, @Next () next) {
238+ middleware .graphqlRouteHandler (new PostGraphileResponseNode (request, response, next));
239+ }
240+ }
241+ ```
242+
221243** IMPORTANT** : although it's tempting to add your handlers with explicitly
222244written paths, e.g. ` app.post('/graphql', ...) ` , it's better to use the relevant
223245middleware properties such as ` middleware.graphqlRoute ` to ensure that
0 commit comments