From 5ff372070d150cd7fcb189c8149eb25098f148bd Mon Sep 17 00:00:00 2001 From: Dan Caddigan Date: Sun, 16 Jan 2022 15:31:11 -0500 Subject: [PATCH] fix(one-to-many): makes one to manys required (#482) --- .../generated/binding.ts | 2 +- .../generated/schema.graphql | 2 +- .../generated/binding.ts | 12 +- .../generated/schema.graphql | 12 +- .../07-feature-flags/generated/binding.ts | 32 ++-- .../07-feature-flags/generated/schema.graphql | 32 ++-- examples/08-performance/generated/binding.ts | 2 +- .../08-performance/generated/schema.graphql | 2 +- examples/09-production/generated/classes.ts | 58 -------- .../10-subscriptions/generated/binding.ts | 20 ++- .../10-subscriptions/generated/classes.ts | 26 ++-- .../10-subscriptions/generated/schema.graphql | 18 ++- examples/11-transactions/generated/binding.ts | 20 ++- examples/11-transactions/generated/classes.ts | 26 ++-- .../11-transactions/generated/schema.graphql | 18 ++- .../14-base-service-v2/generated/binding.ts | 66 +-------- .../14-base-service-v2/generated/classes.ts | 139 +----------------- .../generated/schema.graphql | 64 +------- src/decorators/ManyToOne.ts | 4 +- src/decorators/OneToMany.ts | 2 +- tools/bootstrap-all.sh | 4 +- 21 files changed, 143 insertions(+), 418 deletions(-) diff --git a/examples/03-one-to-many-relationship/generated/binding.ts b/examples/03-one-to-many-relationship/generated/binding.ts index 859aa4d4..f2dbdfb9 100644 --- a/examples/03-one-to-many-relationship/generated/binding.ts +++ b/examples/03-one-to-many-relationship/generated/binding.ts @@ -238,7 +238,7 @@ export interface User { version: Int ownerId: ID_Output firstName: String - posts?: Array | null + posts: Array } /* diff --git a/examples/03-one-to-many-relationship/generated/schema.graphql b/examples/03-one-to-many-relationship/generated/schema.graphql index 38e98a2d..c3c19853 100644 --- a/examples/03-one-to-many-relationship/generated/schema.graphql +++ b/examples/03-one-to-many-relationship/generated/schema.graphql @@ -140,7 +140,7 @@ type User { version: Int! ownerId: ID! firstName: String! - posts: [Post!] + posts: [Post!]! } input UserCreateInput { diff --git a/examples/04-many-to-many-relationship/generated/binding.ts b/examples/04-many-to-many-relationship/generated/binding.ts index 53053268..699535ca 100644 --- a/examples/04-many-to-many-relationship/generated/binding.ts +++ b/examples/04-many-to-many-relationship/generated/binding.ts @@ -413,7 +413,7 @@ export interface Author { version: Int ownerId: ID_Output firstName: String - posts?: Array | null + posts: Array } export interface PageInfo { @@ -434,7 +434,7 @@ export interface Post { version: Int ownerId: ID_Output name: String - authors?: Array | null + authors: Array posts: Array } @@ -449,7 +449,7 @@ export interface Role { version: Int ownerId: ID_Output name: String - userRoles?: Array | null + userRoles: Array } export interface StandardDeleteResponse { @@ -467,7 +467,7 @@ export interface User { version: Int ownerId: ID_Output firstName: String - userRoles?: Array | null + userRoles: Array } export interface UserRole { @@ -480,9 +480,9 @@ export interface UserRole { deletedById?: ID_Output | null version: Int ownerId: ID_Output - user?: User | null + user: User userId: ID_Output - role?: Role | null + role: Role roleId: ID_Output otherMetadata?: String | null } diff --git a/examples/04-many-to-many-relationship/generated/schema.graphql b/examples/04-many-to-many-relationship/generated/schema.graphql index cef6c9e1..95baa8c0 100644 --- a/examples/04-many-to-many-relationship/generated/schema.graphql +++ b/examples/04-many-to-many-relationship/generated/schema.graphql @@ -9,7 +9,7 @@ type Author { version: Int! ownerId: ID! firstName: String! - posts: [Post!] + posts: [Post!]! } input AuthorCreateInput { @@ -122,7 +122,7 @@ type Post { version: Int! ownerId: ID! name: String! - authors: [Author!] + authors: [Author!]! posts: [Post!]! } @@ -218,7 +218,7 @@ type Role { version: Int! ownerId: ID! name: String! - userRoles: [UserRole!] + userRoles: [UserRole!]! } input RoleCreateInput { @@ -287,7 +287,7 @@ type User { version: Int! ownerId: ID! firstName: String! - userRoles: [UserRole!] + userRoles: [UserRole!]! } input UserCreateInput { @@ -327,9 +327,9 @@ type UserRole { deletedById: ID version: Int! ownerId: ID! - user: User + user: User! userId: ID! - role: Role + role: Role! roleId: ID! otherMetadata: String } diff --git a/examples/07-feature-flags/generated/binding.ts b/examples/07-feature-flags/generated/binding.ts index ebda07f2..4227c9f7 100644 --- a/examples/07-feature-flags/generated/binding.ts +++ b/examples/07-feature-flags/generated/binding.ts @@ -914,10 +914,10 @@ export interface Environment { projKey: String project?: Project | null projectId?: ID_Output | null - segments?: Array | null - featureFlagUsers?: Array | null - featureFlagSegments?: Array | null - userSegments?: Array | null + segments: Array + featureFlagUsers: Array + featureFlagSegments: Array + userSegments: Array } export interface FeatureFlag { @@ -935,8 +935,8 @@ export interface FeatureFlag { projKey: String project?: Project | null projectId?: ID_Output | null - featureFlagUsers?: Array | null - featureFlagSegments?: Array | null + featureFlagUsers: Array + featureFlagSegments: Array } export interface FeatureFlagSegment { @@ -1006,12 +1006,12 @@ export interface Project { ownerId: ID_Output name: String key: String - environments?: Array | null - segments?: Array | null - featureFlags?: Array | null - featureFlagUsers?: Array | null - featureFlagSegments?: Array | null - userSegments?: Array | null + environments: Array + segments: Array + featureFlags: Array + featureFlagUsers: Array + featureFlagSegments: Array + userSegments: Array } export interface Segment { @@ -1033,8 +1033,8 @@ export interface Segment { envKey: String environment?: Environment | null environmentId?: ID_Output | null - featureFlagSegments?: Array | null - userSegments?: Array | null + featureFlagSegments: Array + userSegments: Array } export interface StandardDeleteResponse { @@ -1052,8 +1052,8 @@ export interface User { version: Int ownerId: ID_Output key: String - featureFlagUsers?: Array | null - userSegments?: Array | null + featureFlagUsers: Array + userSegments: Array } export interface UserSegment { diff --git a/examples/07-feature-flags/generated/schema.graphql b/examples/07-feature-flags/generated/schema.graphql index eb968a3d..f9c154e4 100644 --- a/examples/07-feature-flags/generated/schema.graphql +++ b/examples/07-feature-flags/generated/schema.graphql @@ -22,10 +22,10 @@ type Environment { projKey: String! project: Project projectId: ID - segments: [Segment!] - featureFlagUsers: [FeatureFlagUser!] - featureFlagSegments: [FeatureFlagSegment!] - userSegments: [UserSegment!] + segments: [Segment!]! + featureFlagUsers: [FeatureFlagUser!]! + featureFlagSegments: [FeatureFlagSegment!]! + userSegments: [UserSegment!]! } input EnvironmentCreateInput { @@ -141,8 +141,8 @@ type FeatureFlag { projKey: String! project: Project projectId: ID - featureFlagUsers: [FeatureFlagUser!] - featureFlagSegments: [FeatureFlagSegment!] + featureFlagUsers: [FeatureFlagUser!]! + featureFlagSegments: [FeatureFlagSegment!]! } input FeatureFlagCreateInput { @@ -590,12 +590,12 @@ type Project { ownerId: ID! name: String! key: String! - environments: [Environment!] - segments: [Segment!] - featureFlags: [FeatureFlag!] - featureFlagUsers: [FeatureFlagUser!] - featureFlagSegments: [FeatureFlagSegment!] - userSegments: [UserSegment!] + environments: [Environment!]! + segments: [Segment!]! + featureFlags: [FeatureFlag!]! + featureFlagUsers: [FeatureFlagUser!]! + featureFlagSegments: [FeatureFlagSegment!]! + userSegments: [UserSegment!]! } input ProjectCreateInput { @@ -720,8 +720,8 @@ type Segment { envKey: String! environment: Environment environmentId: ID - featureFlagSegments: [FeatureFlagSegment!] - userSegments: [UserSegment!] + featureFlagSegments: [FeatureFlagSegment!]! + userSegments: [UserSegment!]! } input SegmentCreateInput { @@ -861,8 +861,8 @@ type User { version: Int! ownerId: ID! key: String! - featureFlagUsers: [FeatureFlagUser!] - userSegments: [UserSegment!] + featureFlagUsers: [FeatureFlagUser!]! + userSegments: [UserSegment!]! } input UserCreateInput { diff --git a/examples/08-performance/generated/binding.ts b/examples/08-performance/generated/binding.ts index 447c7197..51229cea 100644 --- a/examples/08-performance/generated/binding.ts +++ b/examples/08-performance/generated/binding.ts @@ -241,7 +241,7 @@ export interface User { version: Int ownerId: ID_Output firstName: String - posts?: Array | null + posts: Array } /* diff --git a/examples/08-performance/generated/schema.graphql b/examples/08-performance/generated/schema.graphql index 9d66bbdb..a9b47ed0 100644 --- a/examples/08-performance/generated/schema.graphql +++ b/examples/08-performance/generated/schema.graphql @@ -142,7 +142,7 @@ type User { version: Int! ownerId: ID! firstName: String! - posts: [Post!] + posts: [Post!]! } input UserCreateInput { diff --git a/examples/09-production/generated/classes.ts b/examples/09-production/generated/classes.ts index 2877d575..091ae640 100644 --- a/examples/09-production/generated/classes.ts +++ b/examples/09-production/generated/classes.ts @@ -21,61 +21,3 @@ const { GraphQLJSONObject } = require('graphql-type-json'); // @ts-ignore import { BaseWhereInput, JsonObject, PaginationArgs, DateOnlyString, DateTimeString, IDType } from '../../../src'; - -// @ts-ignore - -import { User } from "../dist/examples/09-production/src/modules/user/user.model"; - -export enum UserOrderByEnum { - id_ASC = "id_ASC", - id_DESC = "id_DESC" -} - -registerEnumType(UserOrderByEnum, { - name: "UserOrderByInput" -}); - -@TypeGraphQLInputType() -export class UserWhereInput { - @TypeGraphQLField(() => [ID], { nullable: true }) - id_in?: string[]; -} - -@TypeGraphQLInputType() -export class UserWhereUniqueInput { - @TypeGraphQLField(() => ID) - id?: string; -} - -@TypeGraphQLInputType() -export class UserCreateInput { - @TypeGraphQLField() - firstName!: string; -} - -@TypeGraphQLInputType() -export class UserUpdateInput { - @TypeGraphQLField({ nullable: true }) - firstName?: string; -} - -@ArgsType() -export class UserWhereArgs extends PaginationArgs { - @TypeGraphQLField(() => UserWhereInput, { nullable: true }) - where?: UserWhereInput; - - @TypeGraphQLField(() => UserOrderByEnum, { nullable: true }) - orderBy?: UserOrderByEnum; -} - -@ArgsType() -export class UserCreateManyArgs { - @TypeGraphQLField(() => [UserCreateInput]) - data!: UserCreateInput[]; -} - -@ArgsType() -export class UserUpdateArgs { - @TypeGraphQLField() data!: UserUpdateInput; - @TypeGraphQLField() where!: UserWhereUniqueInput; -} diff --git a/examples/10-subscriptions/generated/binding.ts b/examples/10-subscriptions/generated/binding.ts index 7936f465..c2776284 100644 --- a/examples/10-subscriptions/generated/binding.ts +++ b/examples/10-subscriptions/generated/binding.ts @@ -48,8 +48,6 @@ export type UserOrderByInput = 'firstName_ASC' | 'firstName_DESC' | 'lastName_ASC' | 'lastName_DESC' | - 'id_ASC' | - 'id_DESC' | 'createdAt_ASC' | 'createdAt_DESC' | 'createdById_ASC' | @@ -63,7 +61,11 @@ export type UserOrderByInput = 'firstName_ASC' | 'deletedById_ASC' | 'deletedById_DESC' | 'version_ASC' | - 'version_DESC' + 'version_DESC' | + 'ownerId_ASC' | + 'ownerId_DESC' | + 'id_ASC' | + 'id_DESC' export interface UserCreateInput { firstName: String @@ -86,8 +88,6 @@ export interface UserWhereInput { lastName_startsWith?: String | null lastName_endsWith?: String | null lastName_in?: String[] | String | null - id_eq?: ID_Input | null - id_in?: ID_Output[] | ID_Output | null createdAt_eq?: DateTime | null createdAt_lt?: DateTime | null createdAt_lte?: DateTime | null @@ -116,6 +116,9 @@ export interface UserWhereInput { 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 UserWhereUniqueInput { @@ -140,12 +143,13 @@ export interface StandardDeleteResponse { export interface User { id: ID_Output createdAt: DateTime - createdById: String + createdById: ID_Output updatedAt?: DateTime | null - updatedById?: String | null + updatedById?: ID_Output | null deletedAt?: DateTime | null - deletedById?: String | null + deletedById?: ID_Output | null version: Int + ownerId: ID_Output firstName: String lastName: String } diff --git a/examples/10-subscriptions/generated/classes.ts b/examples/10-subscriptions/generated/classes.ts index dcbf45b6..3c8ce3c6 100644 --- a/examples/10-subscriptions/generated/classes.ts +++ b/examples/10-subscriptions/generated/classes.ts @@ -33,9 +33,6 @@ export enum UserOrderByEnum { lastName_ASC = "lastName_ASC", lastName_DESC = "lastName_DESC", - id_ASC = "id_ASC", - id_DESC = "id_DESC", - createdAt_ASC = "createdAt_ASC", createdAt_DESC = "createdAt_DESC", @@ -55,7 +52,13 @@ export enum UserOrderByEnum { deletedById_DESC = "deletedById_DESC", version_ASC = "version_ASC", - version_DESC = "version_DESC" + version_DESC = "version_DESC", + + ownerId_ASC = "ownerId_ASC", + ownerId_DESC = "ownerId_DESC", + + id_ASC = "id_ASC", + id_DESC = "id_DESC" } registerEnumType(UserOrderByEnum, { @@ -94,12 +97,6 @@ export class UserWhereInput { @TypeGraphQLField(() => [String], { nullable: true }) lastName_in?: string[]; - @TypeGraphQLField(() => ID, { nullable: true }) - id_eq?: string; - - @TypeGraphQLField(() => [ID], { nullable: true }) - id_in?: string[]; - @TypeGraphQLField(() => DateTime, { nullable: true }) createdAt_eq?: DateTimeString; @@ -183,6 +180,15 @@ export class UserWhereInput { @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() diff --git a/examples/10-subscriptions/generated/schema.graphql b/examples/10-subscriptions/generated/schema.graphql index 1aa509b2..124abb14 100644 --- a/examples/10-subscriptions/generated/schema.graphql +++ b/examples/10-subscriptions/generated/schema.graphql @@ -36,12 +36,13 @@ type Subscription { type User { id: ID! createdAt: DateTime! - createdById: String! + createdById: ID! updatedAt: DateTime - updatedById: String + updatedById: ID deletedAt: DateTime - deletedById: String + deletedById: ID version: Int! + ownerId: ID! firstName: String! lastName: String! } @@ -56,8 +57,6 @@ enum UserOrderByInput { firstName_DESC lastName_ASC lastName_DESC - id_ASC - id_DESC createdAt_ASC createdAt_DESC createdById_ASC @@ -72,6 +71,10 @@ enum UserOrderByInput { deletedById_DESC version_ASC version_DESC + ownerId_ASC + ownerId_DESC + id_ASC + id_DESC } input UserUpdateInput { @@ -90,8 +93,6 @@ input UserWhereInput { lastName_startsWith: String lastName_endsWith: String lastName_in: [String!] - id_eq: ID - id_in: [ID!] createdAt_eq: DateTime createdAt_lt: DateTime createdAt_lte: DateTime @@ -120,6 +121,9 @@ input UserWhereInput { version_lt: Int version_lte: Int version_in: [Int!] + ownerId_eq: ID + ownerId_in: [ID!] + id_in: [ID!] } input UserWhereUniqueInput { diff --git a/examples/11-transactions/generated/binding.ts b/examples/11-transactions/generated/binding.ts index d1524524..8c708370 100644 --- a/examples/11-transactions/generated/binding.ts +++ b/examples/11-transactions/generated/binding.ts @@ -44,8 +44,6 @@ export type UserOrderByInput = 'firstName_ASC' | 'firstName_DESC' | 'lastName_ASC' | 'lastName_DESC' | - 'id_ASC' | - 'id_DESC' | 'createdAt_ASC' | 'createdAt_DESC' | 'createdById_ASC' | @@ -59,7 +57,11 @@ export type UserOrderByInput = 'firstName_ASC' | 'deletedById_ASC' | 'deletedById_DESC' | 'version_ASC' | - 'version_DESC' + 'version_DESC' | + 'ownerId_ASC' | + 'ownerId_DESC' | + 'id_ASC' | + 'id_DESC' export interface UserCreateInput { firstName: String @@ -82,8 +84,6 @@ export interface UserWhereInput { lastName_startsWith?: String | null lastName_endsWith?: String | null lastName_in?: String[] | String | null - id_eq?: ID_Input | null - id_in?: ID_Output[] | ID_Output | null createdAt_eq?: DateTime | null createdAt_lt?: DateTime | null createdAt_lte?: DateTime | null @@ -112,6 +112,9 @@ export interface UserWhereInput { 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 UserWhereUniqueInput { @@ -136,12 +139,13 @@ export interface StandardDeleteResponse { export interface User { id: ID_Output createdAt: DateTime - createdById: String + createdById: ID_Output updatedAt?: DateTime | null - updatedById?: String | null + updatedById?: ID_Output | null deletedAt?: DateTime | null - deletedById?: String | null + deletedById?: ID_Output | null version: Int + ownerId: ID_Output firstName: String lastName: String } diff --git a/examples/11-transactions/generated/classes.ts b/examples/11-transactions/generated/classes.ts index dcbf45b6..3c8ce3c6 100644 --- a/examples/11-transactions/generated/classes.ts +++ b/examples/11-transactions/generated/classes.ts @@ -33,9 +33,6 @@ export enum UserOrderByEnum { lastName_ASC = "lastName_ASC", lastName_DESC = "lastName_DESC", - id_ASC = "id_ASC", - id_DESC = "id_DESC", - createdAt_ASC = "createdAt_ASC", createdAt_DESC = "createdAt_DESC", @@ -55,7 +52,13 @@ export enum UserOrderByEnum { deletedById_DESC = "deletedById_DESC", version_ASC = "version_ASC", - version_DESC = "version_DESC" + version_DESC = "version_DESC", + + ownerId_ASC = "ownerId_ASC", + ownerId_DESC = "ownerId_DESC", + + id_ASC = "id_ASC", + id_DESC = "id_DESC" } registerEnumType(UserOrderByEnum, { @@ -94,12 +97,6 @@ export class UserWhereInput { @TypeGraphQLField(() => [String], { nullable: true }) lastName_in?: string[]; - @TypeGraphQLField(() => ID, { nullable: true }) - id_eq?: string; - - @TypeGraphQLField(() => [ID], { nullable: true }) - id_in?: string[]; - @TypeGraphQLField(() => DateTime, { nullable: true }) createdAt_eq?: DateTimeString; @@ -183,6 +180,15 @@ export class UserWhereInput { @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() diff --git a/examples/11-transactions/generated/schema.graphql b/examples/11-transactions/generated/schema.graphql index fcca0695..62ae0a48 100644 --- a/examples/11-transactions/generated/schema.graphql +++ b/examples/11-transactions/generated/schema.graphql @@ -30,12 +30,13 @@ type StandardDeleteResponse { type User { id: ID! createdAt: DateTime! - createdById: String! + createdById: ID! updatedAt: DateTime - updatedById: String + updatedById: ID deletedAt: DateTime - deletedById: String + deletedById: ID version: Int! + ownerId: ID! firstName: String! lastName: String! } @@ -50,8 +51,6 @@ enum UserOrderByInput { firstName_DESC lastName_ASC lastName_DESC - id_ASC - id_DESC createdAt_ASC createdAt_DESC createdById_ASC @@ -66,6 +65,10 @@ enum UserOrderByInput { deletedById_DESC version_ASC version_DESC + ownerId_ASC + ownerId_DESC + id_ASC + id_DESC } input UserUpdateInput { @@ -84,8 +87,6 @@ input UserWhereInput { lastName_startsWith: String lastName_endsWith: String lastName_in: [String!] - id_eq: ID - id_in: [ID!] createdAt_eq: DateTime createdAt_lt: DateTime createdAt_lte: DateTime @@ -114,6 +115,9 @@ input UserWhereInput { version_lt: Int version_lte: Int version_in: [Int!] + ownerId_eq: ID + ownerId_in: [ID!] + id_in: [ID!] } input UserWhereUniqueInput { diff --git a/examples/14-base-service-v2/generated/binding.ts b/examples/14-base-service-v2/generated/binding.ts index ca474540..abe20f00 100644 --- a/examples/14-base-service-v2/generated/binding.ts +++ b/examples/14-base-service-v2/generated/binding.ts @@ -46,27 +46,7 @@ export type Status = 'ACTIVE' | 'INACTIVE' export type UserOrderByInput = 'firstName_ASC' | - 'firstName_DESC' | - 'lastName_ASC' | - 'lastName_DESC' | - 'status_ASC' | - 'status_DESC' | - 'id_ASC' | - 'id_DESC' | - 'createdAt_ASC' | - 'createdAt_DESC' | - 'createdById_ASC' | - 'createdById_DESC' | - 'updatedAt_ASC' | - 'updatedAt_DESC' | - 'updatedById_ASC' | - 'updatedById_DESC' | - 'deletedAt_ASC' | - 'deletedAt_DESC' | - 'deletedById_ASC' | - 'deletedById_DESC' | - 'version_ASC' | - 'version_DESC' + 'firstName_DESC' export interface UserCreateInput { firstName: String @@ -83,43 +63,8 @@ export interface UserUpdateInput { export interface UserWhereInput { firstName_eq?: String | null firstName_contains?: String | null - lastName_eq?: String | null - lastName_contains?: String | null - lastName_startsWith?: String | null - lastName_endsWith?: String | null - lastName_in?: String[] | String | null - status_eq?: Status | null - status_in?: Status[] | Status | null - id_eq?: ID_Input | null - id_in?: ID_Output[] | ID_Output | 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 + id_in?: ID_Output[] | ID_Output | null } export interface UserWhereUniqueInput { @@ -144,12 +89,13 @@ export interface StandardDeleteResponse { export interface User { id: ID_Output createdAt: DateTime - createdById: String + createdById: ID_Output updatedAt?: DateTime | null - updatedById?: String | null + updatedById?: ID_Output | null deletedAt?: DateTime | null - deletedById?: String | null + deletedById?: ID_Output | null version: Int + ownerId: ID_Output firstName: String lastName: String status: Status diff --git a/examples/14-base-service-v2/generated/classes.ts b/examples/14-base-service-v2/generated/classes.ts index 5ea8885a..7d9eaf56 100644 --- a/examples/14-base-service-v2/generated/classes.ts +++ b/examples/14-base-service-v2/generated/classes.ts @@ -30,37 +30,7 @@ import { User } from "../src/user.model"; export enum UserOrderByEnum { firstName_ASC = "firstName_ASC", - firstName_DESC = "firstName_DESC", - - lastName_ASC = "lastName_ASC", - lastName_DESC = "lastName_DESC", - - status_ASC = "status_ASC", - status_DESC = "status_DESC", - - id_ASC = "id_ASC", - id_DESC = "id_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" + firstName_DESC = "firstName_DESC" } registerEnumType(UserOrderByEnum, { @@ -75,116 +45,11 @@ export class UserWhereInput { @TypeGraphQLField({ nullable: true }) firstName_contains?: string; - @TypeGraphQLField({ nullable: true }) - lastName_eq?: string; - - @TypeGraphQLField({ nullable: true }) - lastName_contains?: string; - - @TypeGraphQLField({ nullable: true }) - lastName_startsWith?: string; - - @TypeGraphQLField({ nullable: true }) - lastName_endsWith?: string; - - @TypeGraphQLField(() => [String], { nullable: true }) - lastName_in?: string[]; - - @TypeGraphQLField(() => Status, { nullable: true }) - status_eq?: Status; - - @TypeGraphQLField(() => [Status], { nullable: true }) - status_in?: Status[]; - - @TypeGraphQLField(() => ID, { nullable: true }) - id_eq?: string; - - @TypeGraphQLField(() => [ID], { nullable: true }) - id_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[]; + id_in?: string[]; } @TypeGraphQLInputType() diff --git a/examples/14-base-service-v2/generated/schema.graphql b/examples/14-base-service-v2/generated/schema.graphql index 7e212e4a..95aa5894 100644 --- a/examples/14-base-service-v2/generated/schema.graphql +++ b/examples/14-base-service-v2/generated/schema.graphql @@ -37,12 +37,13 @@ enum Status { type User { id: ID! createdAt: DateTime! - createdById: String! + createdById: ID! updatedAt: DateTime - updatedById: String + updatedById: ID deletedAt: DateTime - deletedById: String + deletedById: ID version: Int! + ownerId: ID! firstName: String! lastName: String! status: Status! @@ -57,26 +58,6 @@ input UserCreateInput { enum UserOrderByInput { firstName_ASC firstName_DESC - lastName_ASC - lastName_DESC - status_ASC - status_DESC - id_ASC - id_DESC - createdAt_ASC - createdAt_DESC - createdById_ASC - createdById_DESC - updatedAt_ASC - updatedAt_DESC - updatedById_ASC - updatedById_DESC - deletedAt_ASC - deletedAt_DESC - deletedById_ASC - deletedById_DESC - version_ASC - version_DESC } input UserUpdateInput { @@ -88,43 +69,8 @@ input UserUpdateInput { input UserWhereInput { firstName_eq: String firstName_contains: String - lastName_eq: String - lastName_contains: String - lastName_startsWith: String - lastName_endsWith: String - lastName_in: [String!] - status_eq: Status - status_in: [Status!] - id_eq: ID - id_in: [ID!] - createdAt_eq: DateTime - createdAt_lt: DateTime - createdAt_lte: DateTime - createdAt_gt: DateTime - createdAt_gte: DateTime - createdById_eq: ID - createdById_in: [ID!] - updatedAt_eq: DateTime - updatedAt_lt: DateTime - updatedAt_lte: DateTime - updatedAt_gt: DateTime - updatedAt_gte: DateTime - updatedById_eq: ID - updatedById_in: [ID!] deletedAt_all: Boolean - deletedAt_eq: DateTime - deletedAt_lt: DateTime - deletedAt_lte: DateTime - deletedAt_gt: DateTime - deletedAt_gte: DateTime - deletedById_eq: ID - deletedById_in: [ID!] - version_eq: Int - version_gt: Int - version_gte: Int - version_lt: Int - version_lte: Int - version_in: [Int!] + id_in: [ID!] } input UserWhereUniqueInput { diff --git a/src/decorators/ManyToOne.ts b/src/decorators/ManyToOne.ts index 499016f3..b8ba4f20 100644 --- a/src/decorators/ManyToOne.ts +++ b/src/decorators/ManyToOne.ts @@ -1,8 +1,6 @@ import 'reflect-metadata'; - import { Field } from 'type-graphql'; import { JoinColumn, ManyToOne as TypeORMManyToOne } from 'typeorm'; - import { IdField } from '../decorators'; import { composeMethodDecorators, MethodDecoratorFactory } from '../utils'; @@ -30,7 +28,7 @@ export function ManyToOne(parentType: any, joinFunc: any, options: any = {}): an // NOTE: this is unnecessary, but I'm keeping it around because otherwise it will generate the schema properties in a different order // It could otherwise safely be deleted const graphQLdecorator = [ - Field(parentType, { nullable: true, ...options }) as MethodDecoratorFactory + Field(parentType, { nullable: false, ...options }) as MethodDecoratorFactory ]; // END NOTE diff --git a/src/decorators/OneToMany.ts b/src/decorators/OneToMany.ts index 80fe78e8..921cebba 100644 --- a/src/decorators/OneToMany.ts +++ b/src/decorators/OneToMany.ts @@ -4,7 +4,7 @@ import { composeMethodDecorators, MethodDecoratorFactory } from '../utils'; export function OneToMany(parentType: any, joinFunc: any, options: any = {}): any { const factories = [ - Field(parentType, { ...options }) as MethodDecoratorFactory, + Field(parentType, { nullable: false, ...options }) as MethodDecoratorFactory, TypeORMOneToMany(parentType, joinFunc) as MethodDecoratorFactory ]; diff --git a/tools/bootstrap-all.sh b/tools/bootstrap-all.sh index 519d98bd..afa3de9a 100755 --- a/tools/bootstrap-all.sh +++ b/tools/bootstrap-all.sh @@ -7,7 +7,7 @@ do # yarn upgrade && npx syncyarnlock -s -k && yarn # rm -rf generated # yarn db:drop - yarn bootstrap - # yarn codegen + # yarn bootstrap + yarn codegen cd - done