Skip to content

Commit 39c1122

Browse files
authored
Merge branch 'master' into enable-nested-auth
2 parents f8751c5 + 1d57489 commit 39c1122

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+5072
-1114
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ jobs:
3434
GITHUB_HEAD_REF: ${{ steps.script.outputs.headRef }}
3535
GITHUB_BASE_REF: ${{ steps.script.outputs.tagHash }}
3636
steps:
37-
- uses: actions/checkout@v2
37+
- uses: actions/checkout@v4
3838
with:
3939
fetch-depth: 0
4040

4141
- name: Cache node modules
4242
id: cache
43-
uses: actions/cache@v2
43+
uses: actions/cache@v4
4444
with:
4545
path: |
4646
**/node_modules
@@ -58,12 +58,12 @@ jobs:
5858
needs: [ prepare-env ]
5959
runs-on: ubuntu-latest
6060
steps:
61-
- uses: actions/checkout@v2
61+
- uses: actions/checkout@v4
6262
with:
6363
fetch-depth: 0
6464

6565
- name: Cache node modules
66-
uses: actions/cache@v2
66+
uses: actions/cache@v4
6767
with:
6868
path: |
6969
**/node_modules

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ jobs:
2626
target: [ 'build', 'test', 'lint' ]
2727
steps:
2828
- name: Use Node.js ${{ matrix.node-version }}
29-
uses: actions/setup-node@v2
29+
uses: actions/setup-node@v4
3030
with:
3131
node-version: ${{ matrix.node-version }}
3232

33-
- uses: actions/checkout@v3
33+
- uses: actions/checkout@v4
3434
with:
3535
fetch-depth: 0
3636

@@ -69,11 +69,11 @@ jobs:
6969
db-type: ['postgres', 'mysql']
7070
steps:
7171
- name: Use Node.js ${{ matrix.node-version }}
72-
uses: actions/setup-node@v2
72+
uses: actions/setup-node@v4
7373
with:
7474
node-version: ${{ matrix.node-version }}
7575

76-
- uses: actions/checkout@v3
76+
- uses: actions/checkout@v4
7777
with:
7878
fetch-depth: 0
7979

CHANGELOG.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,56 @@
11

2+
# [9.1.0](https://github.com/TriPSs/nestjs-query/compare/v9.0.3...v9.1.0) (2025-07-15)
3+
4+
5+
### Bug Fixes
6+
7+
* **lint:** resolve various linting errors ([f71e99d](https://github.com/TriPSs/nestjs-query/commit/f71e99da1d7f3ad8a9a40c004b1e70d89f7fef07))
8+
9+
10+
### Features
11+
12+
* **examples, query-graphql:** add typegoose discriminator e2e test and fix array filtering ([ab29f94](https://github.com/TriPSs/nestjs-query/commit/ab29f943b5d199a3484d834e65b5702e1fb9382c))
13+
14+
15+
16+
## [9.0.3](https://github.com/TriPSs/nestjs-query/compare/v9.0.2...v9.0.3) (2025-05-13)
17+
18+
19+
### Bug Fixes
20+
21+
* describe indentation ([90e4074](https://github.com/TriPSs/nestjs-query/commit/90e4074b3229861636f710b2330f6b427525ffef))
22+
* shouldUseSkipTake to handle nested cases ([ec39883](https://github.com/TriPSs/nestjs-query/commit/ec3988326ded3b378b0f3bbe2c69161eb49c1ebe))
23+
* Update peer dependencies to support NestJS v11 ([55edc6a](https://github.com/TriPSs/nestjs-query/commit/55edc6a58b208853662bc05058e6d92d6dd4af51)), closes [#358](https://github.com/TriPSs/nestjs-query/issues/358)
24+
25+
26+
27+
## [9.0.2](https://github.com/TriPSs/nestjs-query/compare/v9.0.1...v9.0.2) (2025-02-17)
28+
29+
30+
31+
## [9.0.1](https://github.com/TriPSs/nestjs-query/compare/v9.0.0...v9.0.1) (2025-02-17)
32+
33+
34+
### Bug Fixes
35+
36+
* Update peer dependencies to support NestJS v11 ([9471198](https://github.com/TriPSs/nestjs-query/commit/9471198b987139f297a56f1f4ca3ed8b5b5dce96)), closes [#358](https://github.com/TriPSs/nestjs-query/issues/358)
37+
38+
39+
40+
# [9.0.0](https://github.com/TriPSs/nestjs-query/compare/v8.0.3...v9.0.0) (2025-02-13)
41+
42+
43+
### Features
44+
45+
* Updated to NestJS 11 ([8fe3ed9](https://github.com/TriPSs/nestjs-query/commit/8fe3ed98e19b2532526258d17758dc9d4055a521))
46+
47+
48+
### BREAKING CHANGES
49+
50+
* Updated to NestJS 11
51+
52+
53+
254
## [8.0.3](https://github.com/TriPSs/nestjs-query/compare/v8.0.2...v8.0.3) (2025-01-30)
355

456

documentation/docs/persistence/typegoose/relations.mdx

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,85 @@ export class TagDTO {
401401
</TabItem>
402402
</Tabs>
403403

404+
405+
## Discriminators
406+
407+
Typegoose supports mongoose [discriminators](https://mongoosejs.com/docs/discriminators.html). `nestjs-query` provides support for them through the `NestjsQueryTypegooseModule`.
408+
409+
To use discriminators you need to define them in your `NestjsQueryTypegooseModule.forFeature` call.
410+
411+
When working with discriminators, `nestjs-query` requires you to provide a service class for each discriminated entity. This is necessary for the auto-generated resolvers to be created correctly. These service classes are also the perfect place to add any custom business logic for your discriminated entities.
412+
413+
```ts title="todo-item/todo-item.module.ts"
414+
import { NestjsQueryGraphQLModule } from '@ptc-org/nestjs-query-graphql';
415+
import { NestjsQueryTypegooseModule, TypegooseQueryService } from '@ptc-org/nestjs-query-typegoose';
416+
import { Module } from '@nestjs/common';
417+
import { TodoItemEntity } from './entities/todo-item.entity';
418+
import { TodoTaskEntity } from './entities/todo-task.entity';
419+
import { TodoAppointmentEntity } from './entities/todo-appointment.entity';
420+
import { TodoItemDTO } from './dto/todo-item.dto';
421+
import { TodoTaskDTO } from './dto/todo-task.dto';
422+
import { TodoAppointmentDTO } from './dto/todo-appointment.dto';
423+
import { CreateTodoTaskInput } from './dto/create-todo-task.input';
424+
import { CreateTodoAppointmentInput } from './dto/create-todo-appointment.input';
425+
import { InjectModel } from '@m8a/nestjs-typegoose';
426+
import { ReturnModelType } from '@typegoose/typegoose';
427+
428+
const typegooseModule = NestjsQueryTypegooseModule.forFeature([
429+
{
430+
typegooseClass: TodoItemEntity,
431+
discriminators: [
432+
{ typegooseClass: TodoTaskEntity },
433+
{ typegooseClass: TodoAppointmentEntity }
434+
]
435+
}
436+
]);
437+
438+
439+
class TodoTaskEntityService extends TypegooseQueryService<TodoTaskEntity> {
440+
constructor(@InjectModel(TodoTaskEntity) readonly model: ReturnModelType<typeof TodoTaskEntity>) {
441+
super(model)
442+
}
443+
}
444+
445+
class TodoAppointmentService extends TypegooseQueryService<TodoAppointmentEntity> {
446+
constructor(@InjectModel(TodoAppointmentEntity) readonly model: ReturnModelType<typeof TodoAppointmentEntity>) {
447+
super(model)
448+
}
449+
}
450+
451+
@Module({
452+
imports: [
453+
NestjsQueryGraphQLModule.forFeature({
454+
imports: [typegooseModule],
455+
resolvers: [
456+
{
457+
DTOClass: TodoItemDTO,
458+
EntityClass: TodoItemEntity,
459+
create: {disabled: true}, // Disable create for the base entity
460+
update: {disabled: true} // Disable update for the base entity
461+
},
462+
{
463+
DTOClass: TodoTaskDTO,
464+
EntityClass: TodoTaskEntity,
465+
// Tell the resolver to use our custom input for the create operation
466+
CreateDTOClass: CreateTodoTaskInput,
467+
ServiceClass: TodoTaskEntityService
468+
},
469+
{
470+
DTOClass: TodoAppointmentDTO,
471+
EntityClass: TodoAppointmentEntity,
472+
// Tell the resolver to use our custom input for the create operation
473+
CreateDTOClass: CreateTodoAppointmentInput,
474+
ServiceClass: TodoAppointmentService
475+
}
476+
],
477+
services: [
478+
TodoTaskEntityService,
479+
TodoAppointmentService
480+
]
481+
})
482+
]
483+
})
484+
export class TodoItemModule {}
485+
```

examples/nest-cli.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,15 @@
173173
"tsConfigPath": "./tsconfig.json"
174174
}
175175
},
176+
"typegoose-discriminators": {
177+
"type": "application",
178+
"root": "typegoose-discriminators",
179+
"entryFile": "main",
180+
"sourceRoot": "typegoose-discriminators/src",
181+
"compilerOptions": {
182+
"tsConfigPath": "./tsconfig.json"
183+
}
184+
},
176185
"typeorm": {
177186
"type": "application",
178187
"root": "typeorm",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export const TODO_TASK_FRAGMENT = `
2+
fragment TodoTaskFragment on TodoTask {
3+
id
4+
title
5+
completed
6+
documentType
7+
priority
8+
}
9+
`
10+
11+
export const TODO_APPOINTMENT_FRAGMENT = `
12+
fragment TodoAppointmentFragment on TodoAppointment {
13+
id
14+
title
15+
completed
16+
documentType
17+
dateTime
18+
participants
19+
}
20+
`

0 commit comments

Comments
 (0)