Skip to content

Commit 9069c7a

Browse files
committed
refactor(examples/auth): add SubSubTask entity and DTO
1 parent e2d1b2a commit 9069c7a

File tree

7 files changed

+296
-27
lines changed

7 files changed

+296
-27
lines changed

examples/auth/schema.gql

Lines changed: 209 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,64 @@ type LoginResponse {
1818
accessToken: String!
1919
}
2020

21+
type SubSubTask {
22+
id: ID!
23+
title: String!
24+
public: Boolean!
25+
}
26+
27+
type DeleteManyResponse {
28+
"""The number of records deleted."""
29+
deletedCount: Int!
30+
}
31+
32+
type SubSubTaskDeleteResponse {
33+
id: ID
34+
title: String
35+
public: Boolean
36+
}
37+
38+
type UpdateManyResponse {
39+
"""The number of records updated."""
40+
updatedCount: Int!
41+
}
42+
43+
type SubSubTaskEdge {
44+
"""The node containing the SubSubTask"""
45+
node: SubSubTask!
46+
47+
"""Cursor for this node."""
48+
cursor: ConnectionCursor!
49+
}
50+
51+
"""Cursor for paging through collections"""
52+
scalar ConnectionCursor
53+
54+
type PageInfo {
55+
"""true if paging forward and there are more records."""
56+
hasNextPage: Boolean
57+
58+
"""true if paging backwards and there are more records."""
59+
hasPreviousPage: Boolean
60+
61+
"""The cursor of the first returned record."""
62+
startCursor: ConnectionCursor
63+
64+
"""The cursor of the last returned record."""
65+
endCursor: ConnectionCursor
66+
}
67+
68+
type SubSubTaskConnection {
69+
"""Paging information"""
70+
pageInfo: PageInfo!
71+
72+
"""Array of edges."""
73+
edges: [SubSubTaskEdge!]!
74+
75+
"""Fetch total count of records"""
76+
totalCount: Int!
77+
}
78+
2179
type Tag {
2280
id: ID!
2381
name: String!
@@ -176,9 +234,6 @@ input CursorPaging {
176234
last: Int
177235
}
178236

179-
"""Cursor for paging through collections"""
180-
scalar ConnectionCursor
181-
182237
input TodoItemFilter {
183238
and: [TodoItemFilter!]
184239
or: [TodoItemFilter!]
@@ -452,13 +507,44 @@ type SubTask {
452507
todoItemId: String!
453508
createdBy: String
454509
updatedBy: String
510+
subSubTasksAggregate(
511+
"""Filter to find records to aggregate on"""
512+
filter: SubSubTaskAggregateFilter
513+
): [SubTaskSubSubTasksAggregateResponse!]!
455514
owner: User!
456515
todoItem: TodoItem!
516+
subSubTasks(
517+
"""Specify to filter the records returned."""
518+
filter: SubSubTaskFilter! = {}
519+
520+
"""Specify to sort results."""
521+
sorting: [SubSubTaskSort!]! = []
522+
): [SubSubTask!]!
457523
}
458524

459-
type DeleteManyResponse {
460-
"""The number of records deleted."""
461-
deletedCount: Int!
525+
input SubSubTaskAggregateFilter {
526+
and: [SubSubTaskAggregateFilter!]
527+
or: [SubSubTaskAggregateFilter!]
528+
id: IDFilterComparison
529+
public: BooleanFieldComparison
530+
}
531+
532+
input SubSubTaskFilter {
533+
and: [SubSubTaskFilter!]
534+
or: [SubSubTaskFilter!]
535+
id: IDFilterComparison
536+
public: BooleanFieldComparison
537+
}
538+
539+
input SubSubTaskSort {
540+
field: SubSubTaskSortFields!
541+
direction: SortDirection!
542+
nulls: SortNulls
543+
}
544+
545+
enum SubSubTaskSortFields {
546+
id
547+
public
462548
}
463549

464550
type SubTaskDeleteResponse {
@@ -473,11 +559,6 @@ type SubTaskDeleteResponse {
473559
updatedBy: String
474560
}
475561

476-
type UpdateManyResponse {
477-
"""The number of records updated."""
478-
updatedCount: Int!
479-
}
480-
481562
type SubTaskEdge {
482563
"""The node containing the SubTask"""
483564
node: SubTask!
@@ -486,20 +567,6 @@ type SubTaskEdge {
486567
cursor: ConnectionCursor!
487568
}
488569

489-
type PageInfo {
490-
"""true if paging forward and there are more records."""
491-
hasNextPage: Boolean
492-
493-
"""true if paging backwards and there are more records."""
494-
hasPreviousPage: Boolean
495-
496-
"""The cursor of the first returned record."""
497-
startCursor: ConnectionCursor
498-
499-
"""The cursor of the last returned record."""
500-
endCursor: ConnectionCursor
501-
}
502-
503570
type SubTaskConnection {
504571
"""Paging information"""
505572
pageInfo: PageInfo!
@@ -582,6 +649,41 @@ type SubTaskAggregateResponse {
582649
max: SubTaskMaxAggregate
583650
}
584651

652+
type SubTaskSubSubTasksAggregateGroupBy {
653+
id: ID
654+
public: Boolean
655+
}
656+
657+
type SubTaskSubSubTasksCountAggregate {
658+
id: Int
659+
public: Int
660+
}
661+
662+
type SubTaskSubSubTasksSumAggregate {
663+
id: Float
664+
}
665+
666+
type SubTaskSubSubTasksAvgAggregate {
667+
id: Float
668+
}
669+
670+
type SubTaskSubSubTasksMinAggregate {
671+
id: ID
672+
}
673+
674+
type SubTaskSubSubTasksMaxAggregate {
675+
id: ID
676+
}
677+
678+
type SubTaskSubSubTasksAggregateResponse {
679+
groupBy: SubTaskSubSubTasksAggregateGroupBy
680+
count: SubTaskSubSubTasksCountAggregate
681+
sum: SubTaskSubSubTasksSumAggregate
682+
avg: SubTaskSubSubTasksAvgAggregate
683+
min: SubTaskSubSubTasksMinAggregate
684+
max: SubTaskSubSubTasksMaxAggregate
685+
}
686+
585687
type TagDeleteResponse {
586688
id: ID
587689
name: String
@@ -1055,6 +1157,20 @@ type Query {
10551157
"""Specify to sort results."""
10561158
sorting: [SubTaskSort!]! = []
10571159
): SubTaskConnection!
1160+
subSubTask(
1161+
"""The id of the record to find."""
1162+
id: ID!
1163+
): SubSubTask!
1164+
subSubTasks(
1165+
"""Limit or page results."""
1166+
paging: CursorPaging! = {first: 10}
1167+
1168+
"""Specify to filter the records returned."""
1169+
filter: SubSubTaskFilter! = {}
1170+
1171+
"""Specify to sort results."""
1172+
sorting: [SubSubTaskSort!]! = []
1173+
): SubSubTaskConnection!
10581174
tagAggregate(
10591175
"""Filter to find records to aggregate on"""
10601176
filter: TagAggregateFilter
@@ -1095,6 +1211,12 @@ type Mutation {
10951211
updateManySubTasks(input: UpdateManySubTasksInput!): UpdateManyResponse!
10961212
deleteOneSubTask(input: DeleteOneSubTaskInput!): SubTaskDeleteResponse!
10971213
deleteManySubTasks(input: DeleteManySubTasksInput!): DeleteManyResponse!
1214+
createOneSubSubTask(input: CreateOneSubSubTaskInput!): SubSubTask!
1215+
createManySubSubTasks(input: CreateManySubSubTasksInput!): [SubSubTask!]!
1216+
updateOneSubSubTask(input: UpdateOneSubSubTaskInput!): SubSubTask!
1217+
updateManySubSubTasks(input: UpdateManySubSubTasksInput!): UpdateManyResponse!
1218+
deleteOneSubSubTask(input: DeleteOneSubSubTaskInput!): SubSubTaskDeleteResponse!
1219+
deleteManySubSubTasks(input: DeleteManySubSubTasksInput!): DeleteManyResponse!
10981220
addTodoItemsToTag(input: AddTodoItemsToTagInput!): Tag!
10991221
setTodoItemsOnTag(input: SetTodoItemsOnTagInput!): Tag!
11001222
removeTodoItemsFromTag(input: RemoveTodoItemsFromTagInput!): Tag!
@@ -1314,6 +1436,68 @@ input SubTaskDeleteFilter {
13141436
updatedBy: StringFieldComparison
13151437
}
13161438

1439+
input CreateOneSubSubTaskInput {
1440+
"""The record to create"""
1441+
subSubTask: CreateSubSubTask!
1442+
}
1443+
1444+
input CreateSubSubTask {
1445+
id: ID!
1446+
title: String!
1447+
public: Boolean!
1448+
}
1449+
1450+
input CreateManySubSubTasksInput {
1451+
"""Array of records to create"""
1452+
subSubTasks: [CreateSubSubTask!]!
1453+
}
1454+
1455+
input UpdateOneSubSubTaskInput {
1456+
"""The id of the record to update"""
1457+
id: ID!
1458+
1459+
"""The update to apply."""
1460+
update: UpdateSubSubTask!
1461+
}
1462+
1463+
input UpdateSubSubTask {
1464+
id: ID
1465+
title: String
1466+
public: Boolean
1467+
}
1468+
1469+
input UpdateManySubSubTasksInput {
1470+
"""Filter used to find fields to update"""
1471+
filter: SubSubTaskUpdateFilter!
1472+
1473+
"""The update to apply to all records found using the filter"""
1474+
update: UpdateSubSubTask!
1475+
}
1476+
1477+
input SubSubTaskUpdateFilter {
1478+
and: [SubSubTaskUpdateFilter!]
1479+
or: [SubSubTaskUpdateFilter!]
1480+
id: IDFilterComparison
1481+
public: BooleanFieldComparison
1482+
}
1483+
1484+
input DeleteOneSubSubTaskInput {
1485+
"""The id of the record to delete."""
1486+
id: ID!
1487+
}
1488+
1489+
input DeleteManySubSubTasksInput {
1490+
"""Filter to find records to delete"""
1491+
filter: SubSubTaskDeleteFilter!
1492+
}
1493+
1494+
input SubSubTaskDeleteFilter {
1495+
and: [SubSubTaskDeleteFilter!]
1496+
or: [SubSubTaskDeleteFilter!]
1497+
id: IDFilterComparison
1498+
public: BooleanFieldComparison
1499+
}
1500+
13171501
input AddTodoItemsToTagInput {
13181502
"""The id of the record."""
13191503
id: ID!

examples/auth/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { TypeOrmModule } from '@nestjs/typeorm'
55

66
import { formatGraphqlError, typeormOrmConfig } from '../../helpers'
77
import { AuthModule } from './auth/auth.module'
8+
import { SubSubTaskModule } from './sub-sub-task/sub-sub-task.module'
89
import { SubTaskModule } from './sub-task/sub-task.module'
910
import { TagModule } from './tag/tag.module'
1011
import { TodoItemModule } from './todo-item/todo-item.module'
@@ -28,6 +29,7 @@ import { UserModule } from './user/user.module'
2829
UserModule,
2930
TodoItemModule,
3031
SubTaskModule,
32+
SubSubTaskModule,
3133
TagModule
3234
]
3335
})
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Field, ID, ObjectType } from '@nestjs/graphql'
2+
import { FilterableField, QueryOptions } from '@ptc-org/nestjs-query-graphql'
3+
4+
@ObjectType('SubSubTask')
5+
@QueryOptions({ enableTotalCount: true })
6+
export class SubSubTaskDTO {
7+
@FilterableField(() => ID)
8+
id!: number
9+
10+
@Field()
11+
title!: string
12+
13+
@FilterableField()
14+
public!: boolean
15+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Column, Entity, JoinColumn, ManyToOne, ObjectType, PrimaryGeneratedColumn } from 'typeorm'
2+
3+
import { SubTaskEntity } from '../sub-task/sub-task.entity'
4+
5+
@Entity({ name: 'sub_sub_task' })
6+
export class SubSubTaskEntity {
7+
@PrimaryGeneratedColumn()
8+
id!: number
9+
10+
@Column()
11+
title!: string
12+
13+
@Column()
14+
public!: boolean
15+
16+
@Column({ nullable: false, name: 'sub_task_id' })
17+
subTaskId!: string
18+
19+
@ManyToOne((): ObjectType<SubTaskEntity> => SubTaskEntity, (st) => st.subSubTasks, {
20+
onDelete: 'CASCADE',
21+
nullable: false
22+
})
23+
@JoinColumn({ name: 'sub_task_id' })
24+
subTask!: SubTaskEntity
25+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Module } from '@nestjs/common'
2+
import { NestjsQueryGraphQLModule } from '@ptc-org/nestjs-query-graphql'
3+
import { NestjsQueryTypeOrmModule } from '@ptc-org/nestjs-query-typeorm'
4+
5+
import { SubSubTaskDTO } from './dto/sub-sub-task.dto'
6+
import { SubSubTaskEntity } from './sub-sub-task.entity'
7+
8+
@Module({
9+
imports: [
10+
NestjsQueryGraphQLModule.forFeature({
11+
imports: [NestjsQueryTypeOrmModule.forFeature([SubSubTaskEntity])],
12+
resolvers: [
13+
{
14+
DTOClass: SubSubTaskDTO,
15+
EntityClass: SubSubTaskEntity
16+
}
17+
]
18+
})
19+
]
20+
})
21+
export class SubSubTaskModule {}

0 commit comments

Comments
 (0)