@@ -117,8 +117,8 @@ Next we need an adaptor to convert a generic PostGraphile route handler into a
117
117
handler that's suitable for your given server framework. We provide the
118
118
following out of the box:
119
119
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)
122
122
- ` PostGraphileResponseKoa ` - for Koa
123
123
- ` PostGraphileResponseFastify3 ` - for Fastify v3
124
124
@@ -218,6 +218,28 @@ if (middleware.options.watchPg) {
218
218
}
219
219
```
220
220
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
+
221
243
** IMPORTANT** : although it's tempting to add your handlers with explicitly
222
244
written paths, e.g. ` app.post('/graphql', ...) ` , it's better to use the relevant
223
245
middleware properties such as ` middleware.graphqlRoute ` to ensure that
0 commit comments