Skip to content

Commit

Permalink
Update resolvers.mdx
Browse files Browse the repository at this point in the history
Enhance the doc for CRUDResolver
  • Loading branch information
davidevernizzi authored and doug-martin committed Oct 23, 2020
1 parent b2fa944 commit 21eb5da
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions documentation/docs/graphql/resolvers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,8 @@ Lets create a new query endpoint that only returns completed `TodoItems`.

First create a file named `types.ts`. And add the following.

**NOTE** IN the case of `CRUDResolver` the DTO (`TodoItemDTO`) must be placed in file on its own and cannot be placed together with the module definition.

```ts title="types.ts"
import { ConnectionType, QueryArgsType } from '@nestjs-query/query-graphql';
import { ArgsType } from '@nestjs/graphql';
Expand Down Expand Up @@ -1399,3 +1401,23 @@ Finally we call the `queryMany` method from the `CRUDResolver` with the new filt
return this.queryMany({ ...query, ...{ filter } });
```

The last step is to add the resolver to the module.

```ts title="todo-items.module.ts"
import { Module } from '@nestjs/common';
import { NestjsQueryTypeOrmModule } from '@nestjs-query/query-typeorm';
import { TodoItemEntity } from './todo-item.entity';
import { TodoItemsService } from './todo-items.service';
import { TodoItemsController } from './todo-items.controller';
import { TodoItemsResolver } from './todo-items.resolver';

@Module({
providers: [TodoItemsService, TodoItemsResolver],
imports: [
NestjsQueryTypeOrmModule.forFeature([TodoItemEntity]),
],
exports: [TodoItemsService],
controllers: [TodoItemsController],
})
export class TodoItemsModule {}
```

0 comments on commit 21eb5da

Please sign in to comment.