Skip to content

Commit 67f756a

Browse files
authored
feat(one-to-one): adds one-to-one decorator (#477)
1 parent 30ba9c4 commit 67f756a

File tree

9 files changed

+397
-19
lines changed

9 files changed

+397
-19
lines changed

examples/01-simple-model/.env

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
NODE_ENV=development
22
PGUSER=postgres
33
WARTHOG_API_BASE_URL=http://localhost:4100
4-
WARTHOG_DB_DATABASE=warthog-example-1
5-
WARTHOG_DB_USERNAME=postgres
6-
WARTHOG_DB_PASSWORD=postgres
4+
WARTHOG_DB_URL=postgres://postgres:postgres@localhost:5432/warthog-example-1
75
WARTHOG_DB_SYNCHRONIZE=true
86
WARTHOG_FILTER_BY_DEFAULT=true

examples/01-simple-model/generated/binding.ts

+73
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ export type UserOrderByInput = 'firstName_ASC' |
5959
'stringEnumField_DESC' |
6060
'rating_ASC' |
6161
'rating_DESC' |
62+
'profileId_ASC' |
63+
'profileId_DESC' |
6264
'createdAt_ASC' |
6365
'createdAt_DESC' |
6466
'createdById_ASC' |
@@ -78,6 +80,57 @@ export type UserOrderByInput = 'firstName_ASC' |
7880
'id_ASC' |
7981
'id_DESC'
8082

83+
export interface ProfileCreateInput {
84+
body: String
85+
}
86+
87+
export interface ProfileUpdateInput {
88+
body?: String | null
89+
}
90+
91+
export interface ProfileWhereInput {
92+
body_eq?: String | null
93+
body_contains?: String | null
94+
body_startsWith?: String | null
95+
body_endsWith?: String | null
96+
body_in?: String[] | String | null
97+
createdAt_eq?: DateTime | null
98+
createdAt_lt?: DateTime | null
99+
createdAt_lte?: DateTime | null
100+
createdAt_gt?: DateTime | null
101+
createdAt_gte?: DateTime | null
102+
createdById_eq?: ID_Input | null
103+
createdById_in?: ID_Output[] | ID_Output | null
104+
updatedAt_eq?: DateTime | null
105+
updatedAt_lt?: DateTime | null
106+
updatedAt_lte?: DateTime | null
107+
updatedAt_gt?: DateTime | null
108+
updatedAt_gte?: DateTime | null
109+
updatedById_eq?: ID_Input | null
110+
updatedById_in?: ID_Output[] | ID_Output | null
111+
deletedAt_all?: Boolean | null
112+
deletedAt_eq?: DateTime | null
113+
deletedAt_lt?: DateTime | null
114+
deletedAt_lte?: DateTime | null
115+
deletedAt_gt?: DateTime | null
116+
deletedAt_gte?: DateTime | null
117+
deletedById_eq?: ID_Input | null
118+
deletedById_in?: ID_Output[] | ID_Output | null
119+
version_eq?: Int | null
120+
version_gt?: Int | null
121+
version_gte?: Int | null
122+
version_lt?: Int | null
123+
version_lte?: Int | null
124+
version_in?: Int[] | Int | null
125+
ownerId_eq?: ID_Input | null
126+
ownerId_in?: ID_Output[] | ID_Output | null
127+
id_in?: ID_Output[] | ID_Output | null
128+
}
129+
130+
export interface ProfileWhereUniqueInput {
131+
id: ID_Output
132+
}
133+
81134
export interface UserCreateInput {
82135
firstName: String
83136
lastName?: String | null
@@ -86,6 +139,7 @@ export interface UserCreateInput {
86139
isRequired: Boolean
87140
stringEnumField: StringEnum
88141
rating: Float
142+
profileId: String
89143
}
90144

91145
export interface UserUpdateInput {
@@ -96,6 +150,7 @@ export interface UserUpdateInput {
96150
isRequired?: Boolean | null
97151
stringEnumField?: StringEnum | null
98152
rating?: Float | null
153+
profileId?: String | null
99154
}
100155

101156
export interface UserWhereInput {
@@ -130,6 +185,8 @@ export interface UserWhereInput {
130185
rating_lt?: Float | null
131186
rating_lte?: Float | null
132187
rating_in?: Float[] | Float | null
188+
profileId_eq?: String | null
189+
profileId_in?: String[] | String | null
133190
createdAt_eq?: DateTime | null
134191
createdAt_lt?: DateTime | null
135192
createdAt_lte?: DateTime | null
@@ -179,6 +236,20 @@ export interface PageInfo {
179236
endCursor?: String | null
180237
}
181238

239+
export interface Profile {
240+
id: ID_Output
241+
createdAt: DateTime
242+
createdById: ID_Output
243+
updatedAt?: DateTime | null
244+
updatedById?: ID_Output | null
245+
deletedAt?: DateTime | null
246+
deletedById?: ID_Output | null
247+
version: Int
248+
ownerId: ID_Output
249+
body: String
250+
user: User
251+
}
252+
182253
export interface StandardDeleteResponse {
183254
id: ID_Output
184255
}
@@ -200,6 +271,8 @@ export interface User {
200271
isRequired: Boolean
201272
stringEnumField: StringEnum
202273
rating: Float
274+
profile: Profile
275+
profileId: String
203276
}
204277

205278
/*

examples/01-simple-model/generated/classes.ts

+205
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ import { StringEnum } from "../src/user.model";
2828

2929
import { User } from "../src/user.model";
3030

31+
// @ts-ignore
32+
33+
import { Profile } from "../src/profile.model";
34+
3135
export enum UserOrderByEnum {
3236
firstName_ASC = "firstName_ASC",
3337
firstName_DESC = "firstName_DESC",
@@ -50,6 +54,9 @@ export enum UserOrderByEnum {
5054
rating_ASC = "rating_ASC",
5155
rating_DESC = "rating_DESC",
5256

57+
profileId_ASC = "profileId_ASC",
58+
profileId_DESC = "profileId_DESC",
59+
5360
createdAt_ASC = "createdAt_ASC",
5461
createdAt_DESC = "createdAt_DESC",
5562

@@ -177,6 +184,12 @@ export class UserWhereInput {
177184
@TypeGraphQLField(() => [Float], { nullable: true })
178185
rating_in?: number[];
179186

187+
@TypeGraphQLField({ nullable: true })
188+
profileId_eq?: string;
189+
190+
@TypeGraphQLField(() => [String], { nullable: true })
191+
profileId_in?: string[];
192+
180193
@TypeGraphQLField(() => DateTime, { nullable: true })
181194
createdAt_eq?: DateTimeString;
182195

@@ -302,6 +315,9 @@ export class UserCreateInput {
302315

303316
@TypeGraphQLField()
304317
rating!: number;
318+
319+
@TypeGraphQLField()
320+
profileId!: string;
305321
}
306322

307323
@TypeGraphQLInputType()
@@ -326,6 +342,9 @@ export class UserUpdateInput {
326342

327343
@TypeGraphQLField({ nullable: true })
328344
rating?: number;
345+
346+
@TypeGraphQLField({ nullable: true })
347+
profileId?: string;
329348
}
330349

331350
@ArgsType()
@@ -348,3 +367,189 @@ export class UserUpdateArgs {
348367
@TypeGraphQLField() data!: UserUpdateInput;
349368
@TypeGraphQLField() where!: UserWhereUniqueInput;
350369
}
370+
371+
export enum ProfileOrderByEnum {
372+
body_ASC = "body_ASC",
373+
body_DESC = "body_DESC",
374+
375+
createdAt_ASC = "createdAt_ASC",
376+
createdAt_DESC = "createdAt_DESC",
377+
378+
createdById_ASC = "createdById_ASC",
379+
createdById_DESC = "createdById_DESC",
380+
381+
updatedAt_ASC = "updatedAt_ASC",
382+
updatedAt_DESC = "updatedAt_DESC",
383+
384+
updatedById_ASC = "updatedById_ASC",
385+
updatedById_DESC = "updatedById_DESC",
386+
387+
deletedAt_ASC = "deletedAt_ASC",
388+
deletedAt_DESC = "deletedAt_DESC",
389+
390+
deletedById_ASC = "deletedById_ASC",
391+
deletedById_DESC = "deletedById_DESC",
392+
393+
version_ASC = "version_ASC",
394+
version_DESC = "version_DESC",
395+
396+
ownerId_ASC = "ownerId_ASC",
397+
ownerId_DESC = "ownerId_DESC",
398+
399+
id_ASC = "id_ASC",
400+
id_DESC = "id_DESC"
401+
}
402+
403+
registerEnumType(ProfileOrderByEnum, {
404+
name: "ProfileOrderByInput"
405+
});
406+
407+
@TypeGraphQLInputType()
408+
export class ProfileWhereInput {
409+
@TypeGraphQLField({ nullable: true })
410+
body_eq?: string;
411+
412+
@TypeGraphQLField({ nullable: true })
413+
body_contains?: string;
414+
415+
@TypeGraphQLField({ nullable: true })
416+
body_startsWith?: string;
417+
418+
@TypeGraphQLField({ nullable: true })
419+
body_endsWith?: string;
420+
421+
@TypeGraphQLField(() => [String], { nullable: true })
422+
body_in?: string[];
423+
424+
@TypeGraphQLField(() => DateTime, { nullable: true })
425+
createdAt_eq?: DateTimeString;
426+
427+
@TypeGraphQLField(() => DateTime, { nullable: true })
428+
createdAt_lt?: DateTimeString;
429+
430+
@TypeGraphQLField(() => DateTime, { nullable: true })
431+
createdAt_lte?: DateTimeString;
432+
433+
@TypeGraphQLField(() => DateTime, { nullable: true })
434+
createdAt_gt?: DateTimeString;
435+
436+
@TypeGraphQLField(() => DateTime, { nullable: true })
437+
createdAt_gte?: DateTimeString;
438+
439+
@TypeGraphQLField(() => ID, { nullable: true })
440+
createdById_eq?: string;
441+
442+
@TypeGraphQLField(() => [ID], { nullable: true })
443+
createdById_in?: string[];
444+
445+
@TypeGraphQLField(() => DateTime, { nullable: true })
446+
updatedAt_eq?: DateTimeString;
447+
448+
@TypeGraphQLField(() => DateTime, { nullable: true })
449+
updatedAt_lt?: DateTimeString;
450+
451+
@TypeGraphQLField(() => DateTime, { nullable: true })
452+
updatedAt_lte?: DateTimeString;
453+
454+
@TypeGraphQLField(() => DateTime, { nullable: true })
455+
updatedAt_gt?: DateTimeString;
456+
457+
@TypeGraphQLField(() => DateTime, { nullable: true })
458+
updatedAt_gte?: DateTimeString;
459+
460+
@TypeGraphQLField(() => ID, { nullable: true })
461+
updatedById_eq?: string;
462+
463+
@TypeGraphQLField(() => [ID], { nullable: true })
464+
updatedById_in?: string[];
465+
466+
@TypeGraphQLField({ nullable: true })
467+
deletedAt_all?: Boolean;
468+
469+
@TypeGraphQLField(() => DateTime, { nullable: true })
470+
deletedAt_eq?: DateTimeString;
471+
472+
@TypeGraphQLField(() => DateTime, { nullable: true })
473+
deletedAt_lt?: DateTimeString;
474+
475+
@TypeGraphQLField(() => DateTime, { nullable: true })
476+
deletedAt_lte?: DateTimeString;
477+
478+
@TypeGraphQLField(() => DateTime, { nullable: true })
479+
deletedAt_gt?: DateTimeString;
480+
481+
@TypeGraphQLField(() => DateTime, { nullable: true })
482+
deletedAt_gte?: DateTimeString;
483+
484+
@TypeGraphQLField(() => ID, { nullable: true })
485+
deletedById_eq?: string;
486+
487+
@TypeGraphQLField(() => [ID], { nullable: true })
488+
deletedById_in?: string[];
489+
490+
@TypeGraphQLField(() => Int, { nullable: true })
491+
version_eq?: number;
492+
493+
@TypeGraphQLField(() => Int, { nullable: true })
494+
version_gt?: number;
495+
496+
@TypeGraphQLField(() => Int, { nullable: true })
497+
version_gte?: number;
498+
499+
@TypeGraphQLField(() => Int, { nullable: true })
500+
version_lt?: number;
501+
502+
@TypeGraphQLField(() => Int, { nullable: true })
503+
version_lte?: number;
504+
505+
@TypeGraphQLField(() => [Int], { nullable: true })
506+
version_in?: number[];
507+
508+
@TypeGraphQLField(() => ID, { nullable: true })
509+
ownerId_eq?: string;
510+
511+
@TypeGraphQLField(() => [ID], { nullable: true })
512+
ownerId_in?: string[];
513+
514+
@TypeGraphQLField(() => [ID], { nullable: true })
515+
id_in?: string[];
516+
}
517+
518+
@TypeGraphQLInputType()
519+
export class ProfileWhereUniqueInput {
520+
@TypeGraphQLField(() => ID)
521+
id?: string;
522+
}
523+
524+
@TypeGraphQLInputType()
525+
export class ProfileCreateInput {
526+
@TypeGraphQLField()
527+
body!: string;
528+
}
529+
530+
@TypeGraphQLInputType()
531+
export class ProfileUpdateInput {
532+
@TypeGraphQLField({ nullable: true })
533+
body?: string;
534+
}
535+
536+
@ArgsType()
537+
export class ProfileWhereArgs extends PaginationArgs {
538+
@TypeGraphQLField(() => ProfileWhereInput, { nullable: true })
539+
where?: ProfileWhereInput;
540+
541+
@TypeGraphQLField(() => ProfileOrderByEnum, { nullable: true })
542+
orderBy?: ProfileOrderByEnum;
543+
}
544+
545+
@ArgsType()
546+
export class ProfileCreateManyArgs {
547+
@TypeGraphQLField(() => [ProfileCreateInput])
548+
data!: ProfileCreateInput[];
549+
}
550+
551+
@ArgsType()
552+
export class ProfileUpdateArgs {
553+
@TypeGraphQLField() data!: ProfileUpdateInput;
554+
@TypeGraphQLField() where!: ProfileWhereUniqueInput;
555+
}

0 commit comments

Comments
 (0)