Skip to content

Commit

Permalink
feat(one-to-one): adds one-to-one decorator (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
goldcaddy77 committed Sep 29, 2021
1 parent 30ba9c4 commit 67f756a
Show file tree
Hide file tree
Showing 9 changed files with 397 additions and 19 deletions.
4 changes: 1 addition & 3 deletions examples/01-simple-model/.env
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
NODE_ENV=development
PGUSER=postgres
WARTHOG_API_BASE_URL=http://localhost:4100
WARTHOG_DB_DATABASE=warthog-example-1
WARTHOG_DB_USERNAME=postgres
WARTHOG_DB_PASSWORD=postgres
WARTHOG_DB_URL=postgres://postgres:postgres@localhost:5432/warthog-example-1
WARTHOG_DB_SYNCHRONIZE=true
WARTHOG_FILTER_BY_DEFAULT=true
73 changes: 73 additions & 0 deletions examples/01-simple-model/generated/binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export type UserOrderByInput = 'firstName_ASC' |
'stringEnumField_DESC' |
'rating_ASC' |
'rating_DESC' |
'profileId_ASC' |
'profileId_DESC' |
'createdAt_ASC' |
'createdAt_DESC' |
'createdById_ASC' |
Expand All @@ -78,6 +80,57 @@ export type UserOrderByInput = 'firstName_ASC' |
'id_ASC' |
'id_DESC'

export interface ProfileCreateInput {
body: String
}

export interface ProfileUpdateInput {
body?: String | null
}

export interface ProfileWhereInput {
body_eq?: String | null
body_contains?: String | null
body_startsWith?: String | null
body_endsWith?: String | null
body_in?: String[] | String | null
createdAt_eq?: DateTime | null
createdAt_lt?: DateTime | null
createdAt_lte?: DateTime | null
createdAt_gt?: DateTime | null
createdAt_gte?: DateTime | null
createdById_eq?: ID_Input | null
createdById_in?: ID_Output[] | ID_Output | null
updatedAt_eq?: DateTime | null
updatedAt_lt?: DateTime | null
updatedAt_lte?: DateTime | null
updatedAt_gt?: DateTime | null
updatedAt_gte?: DateTime | null
updatedById_eq?: ID_Input | null
updatedById_in?: ID_Output[] | ID_Output | null
deletedAt_all?: Boolean | null
deletedAt_eq?: DateTime | null
deletedAt_lt?: DateTime | null
deletedAt_lte?: DateTime | null
deletedAt_gt?: DateTime | null
deletedAt_gte?: DateTime | null
deletedById_eq?: ID_Input | null
deletedById_in?: ID_Output[] | ID_Output | null
version_eq?: Int | null
version_gt?: Int | null
version_gte?: Int | null
version_lt?: Int | null
version_lte?: Int | null
version_in?: Int[] | Int | null
ownerId_eq?: ID_Input | null
ownerId_in?: ID_Output[] | ID_Output | null
id_in?: ID_Output[] | ID_Output | null
}

export interface ProfileWhereUniqueInput {
id: ID_Output
}

export interface UserCreateInput {
firstName: String
lastName?: String | null
Expand All @@ -86,6 +139,7 @@ export interface UserCreateInput {
isRequired: Boolean
stringEnumField: StringEnum
rating: Float
profileId: String
}

export interface UserUpdateInput {
Expand All @@ -96,6 +150,7 @@ export interface UserUpdateInput {
isRequired?: Boolean | null
stringEnumField?: StringEnum | null
rating?: Float | null
profileId?: String | null
}

export interface UserWhereInput {
Expand Down Expand Up @@ -130,6 +185,8 @@ export interface UserWhereInput {
rating_lt?: Float | null
rating_lte?: Float | null
rating_in?: Float[] | Float | null
profileId_eq?: String | null
profileId_in?: String[] | String | null
createdAt_eq?: DateTime | null
createdAt_lt?: DateTime | null
createdAt_lte?: DateTime | null
Expand Down Expand Up @@ -179,6 +236,20 @@ export interface PageInfo {
endCursor?: String | null
}

export interface Profile {
id: ID_Output
createdAt: DateTime
createdById: ID_Output
updatedAt?: DateTime | null
updatedById?: ID_Output | null
deletedAt?: DateTime | null
deletedById?: ID_Output | null
version: Int
ownerId: ID_Output
body: String
user: User
}

export interface StandardDeleteResponse {
id: ID_Output
}
Expand All @@ -200,6 +271,8 @@ export interface User {
isRequired: Boolean
stringEnumField: StringEnum
rating: Float
profile: Profile
profileId: String
}

/*
Expand Down
205 changes: 205 additions & 0 deletions examples/01-simple-model/generated/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import { StringEnum } from "../src/user.model";

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

// @ts-ignore

import { Profile } from "../src/profile.model";

export enum UserOrderByEnum {
firstName_ASC = "firstName_ASC",
firstName_DESC = "firstName_DESC",
Expand All @@ -50,6 +54,9 @@ export enum UserOrderByEnum {
rating_ASC = "rating_ASC",
rating_DESC = "rating_DESC",

profileId_ASC = "profileId_ASC",
profileId_DESC = "profileId_DESC",

createdAt_ASC = "createdAt_ASC",
createdAt_DESC = "createdAt_DESC",

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

@TypeGraphQLField({ nullable: true })
profileId_eq?: string;

@TypeGraphQLField(() => [String], { nullable: true })
profileId_in?: string[];

@TypeGraphQLField(() => DateTime, { nullable: true })
createdAt_eq?: DateTimeString;

Expand Down Expand Up @@ -302,6 +315,9 @@ export class UserCreateInput {

@TypeGraphQLField()
rating!: number;

@TypeGraphQLField()
profileId!: string;
}

@TypeGraphQLInputType()
Expand All @@ -326,6 +342,9 @@ export class UserUpdateInput {

@TypeGraphQLField({ nullable: true })
rating?: number;

@TypeGraphQLField({ nullable: true })
profileId?: string;
}

@ArgsType()
Expand All @@ -348,3 +367,189 @@ export class UserUpdateArgs {
@TypeGraphQLField() data!: UserUpdateInput;
@TypeGraphQLField() where!: UserWhereUniqueInput;
}

export enum ProfileOrderByEnum {
body_ASC = "body_ASC",
body_DESC = "body_DESC",

createdAt_ASC = "createdAt_ASC",
createdAt_DESC = "createdAt_DESC",

createdById_ASC = "createdById_ASC",
createdById_DESC = "createdById_DESC",

updatedAt_ASC = "updatedAt_ASC",
updatedAt_DESC = "updatedAt_DESC",

updatedById_ASC = "updatedById_ASC",
updatedById_DESC = "updatedById_DESC",

deletedAt_ASC = "deletedAt_ASC",
deletedAt_DESC = "deletedAt_DESC",

deletedById_ASC = "deletedById_ASC",
deletedById_DESC = "deletedById_DESC",

version_ASC = "version_ASC",
version_DESC = "version_DESC",

ownerId_ASC = "ownerId_ASC",
ownerId_DESC = "ownerId_DESC",

id_ASC = "id_ASC",
id_DESC = "id_DESC"
}

registerEnumType(ProfileOrderByEnum, {
name: "ProfileOrderByInput"
});

@TypeGraphQLInputType()
export class ProfileWhereInput {
@TypeGraphQLField({ nullable: true })
body_eq?: string;

@TypeGraphQLField({ nullable: true })
body_contains?: string;

@TypeGraphQLField({ nullable: true })
body_startsWith?: string;

@TypeGraphQLField({ nullable: true })
body_endsWith?: string;

@TypeGraphQLField(() => [String], { nullable: true })
body_in?: string[];

@TypeGraphQLField(() => DateTime, { nullable: true })
createdAt_eq?: DateTimeString;

@TypeGraphQLField(() => DateTime, { nullable: true })
createdAt_lt?: DateTimeString;

@TypeGraphQLField(() => DateTime, { nullable: true })
createdAt_lte?: DateTimeString;

@TypeGraphQLField(() => DateTime, { nullable: true })
createdAt_gt?: DateTimeString;

@TypeGraphQLField(() => DateTime, { nullable: true })
createdAt_gte?: DateTimeString;

@TypeGraphQLField(() => ID, { nullable: true })
createdById_eq?: string;

@TypeGraphQLField(() => [ID], { nullable: true })
createdById_in?: string[];

@TypeGraphQLField(() => DateTime, { nullable: true })
updatedAt_eq?: DateTimeString;

@TypeGraphQLField(() => DateTime, { nullable: true })
updatedAt_lt?: DateTimeString;

@TypeGraphQLField(() => DateTime, { nullable: true })
updatedAt_lte?: DateTimeString;

@TypeGraphQLField(() => DateTime, { nullable: true })
updatedAt_gt?: DateTimeString;

@TypeGraphQLField(() => DateTime, { nullable: true })
updatedAt_gte?: DateTimeString;

@TypeGraphQLField(() => ID, { nullable: true })
updatedById_eq?: string;

@TypeGraphQLField(() => [ID], { nullable: true })
updatedById_in?: string[];

@TypeGraphQLField({ nullable: true })
deletedAt_all?: Boolean;

@TypeGraphQLField(() => DateTime, { nullable: true })
deletedAt_eq?: DateTimeString;

@TypeGraphQLField(() => DateTime, { nullable: true })
deletedAt_lt?: DateTimeString;

@TypeGraphQLField(() => DateTime, { nullable: true })
deletedAt_lte?: DateTimeString;

@TypeGraphQLField(() => DateTime, { nullable: true })
deletedAt_gt?: DateTimeString;

@TypeGraphQLField(() => DateTime, { nullable: true })
deletedAt_gte?: DateTimeString;

@TypeGraphQLField(() => ID, { nullable: true })
deletedById_eq?: string;

@TypeGraphQLField(() => [ID], { nullable: true })
deletedById_in?: string[];

@TypeGraphQLField(() => Int, { nullable: true })
version_eq?: number;

@TypeGraphQLField(() => Int, { nullable: true })
version_gt?: number;

@TypeGraphQLField(() => Int, { nullable: true })
version_gte?: number;

@TypeGraphQLField(() => Int, { nullable: true })
version_lt?: number;

@TypeGraphQLField(() => Int, { nullable: true })
version_lte?: number;

@TypeGraphQLField(() => [Int], { nullable: true })
version_in?: number[];

@TypeGraphQLField(() => ID, { nullable: true })
ownerId_eq?: string;

@TypeGraphQLField(() => [ID], { nullable: true })
ownerId_in?: string[];

@TypeGraphQLField(() => [ID], { nullable: true })
id_in?: string[];
}

@TypeGraphQLInputType()
export class ProfileWhereUniqueInput {
@TypeGraphQLField(() => ID)
id?: string;
}

@TypeGraphQLInputType()
export class ProfileCreateInput {
@TypeGraphQLField()
body!: string;
}

@TypeGraphQLInputType()
export class ProfileUpdateInput {
@TypeGraphQLField({ nullable: true })
body?: string;
}

@ArgsType()
export class ProfileWhereArgs extends PaginationArgs {
@TypeGraphQLField(() => ProfileWhereInput, { nullable: true })
where?: ProfileWhereInput;

@TypeGraphQLField(() => ProfileOrderByEnum, { nullable: true })
orderBy?: ProfileOrderByEnum;
}

@ArgsType()
export class ProfileCreateManyArgs {
@TypeGraphQLField(() => [ProfileCreateInput])
data!: ProfileCreateInput[];
}

@ArgsType()
export class ProfileUpdateArgs {
@TypeGraphQLField() data!: ProfileUpdateInput;
@TypeGraphQLField() where!: ProfileWhereUniqueInput;
}

0 comments on commit 67f756a

Please sign in to comment.