diff --git a/examples/ent-rsvp/backend/src/ent/generated/address_base.ts b/examples/ent-rsvp/backend/src/ent/generated/address_base.ts index 0bfe3ee56..196109ff8 100644 --- a/examples/ent-rsvp/backend/src/ent/generated/address_base.ts +++ b/examples/ent-rsvp/backend/src/ent/generated/address_base.ts @@ -177,11 +177,7 @@ export class AddressBase implements Ent { id: ID, context?: Context, ): Promise { - const row = await addressLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return addressLoader.createLoader(context).load(id); } static async loadRawDataX( @@ -247,11 +243,7 @@ export class AddressBase implements Ent { ownerID: ID, context?: Context, ): Promise { - const row = await addressOwnerIDLoader.createLoader(context).load(ownerID); - if (!row) { - return null; - } - return row; + return addressOwnerIDLoader.createLoader(context).load(ownerID); } static loaderOptions( diff --git a/examples/ent-rsvp/backend/src/ent/generated/auth_code_base.ts b/examples/ent-rsvp/backend/src/ent/generated/auth_code_base.ts index 1090996fb..95502d562 100644 --- a/examples/ent-rsvp/backend/src/ent/generated/auth_code_base.ts +++ b/examples/ent-rsvp/backend/src/ent/generated/auth_code_base.ts @@ -170,11 +170,7 @@ export class AuthCodeBase implements Ent { id: ID, context?: Context, ): Promise { - const row = await authCodeLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return authCodeLoader.createLoader(context).load(id); } static async loadRawDataX( @@ -240,11 +236,7 @@ export class AuthCodeBase implements Ent { guestID: ID, context?: Context, ): Promise { - const row = await authCodeGuestIDLoader.createLoader(context).load(guestID); - if (!row) { - return null; - } - return row; + return authCodeGuestIDLoader.createLoader(context).load(guestID); } static loaderOptions( diff --git a/examples/ent-rsvp/backend/src/ent/generated/event_activity_base.ts b/examples/ent-rsvp/backend/src/ent/generated/event_activity_base.ts index 034f05e6a..7880ff0db 100644 --- a/examples/ent-rsvp/backend/src/ent/generated/event_activity_base.ts +++ b/examples/ent-rsvp/backend/src/ent/generated/event_activity_base.ts @@ -192,11 +192,7 @@ export class EventActivityBase id: ID, context?: Context, ): Promise { - const row = await eventActivityLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return eventActivityLoader.createLoader(context).load(id); } static async loadRawDataX( diff --git a/examples/ent-rsvp/backend/src/ent/generated/event_base.ts b/examples/ent-rsvp/backend/src/ent/generated/event_base.ts index ed11c8492..6de206b39 100644 --- a/examples/ent-rsvp/backend/src/ent/generated/event_base.ts +++ b/examples/ent-rsvp/backend/src/ent/generated/event_base.ts @@ -174,11 +174,7 @@ export class EventBase implements Ent { id: ID, context?: Context, ): Promise { - const row = await eventLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return eventLoader.createLoader(context).load(id); } static async loadRawDataX( @@ -244,11 +240,7 @@ export class EventBase implements Ent { slug: string, context?: Context, ): Promise { - const row = await eventSlugLoader.createLoader(context).load(slug); - if (!row) { - return null; - } - return row; + return eventSlugLoader.createLoader(context).load(slug); } static loaderOptions( diff --git a/examples/ent-rsvp/backend/src/ent/generated/guest_base.ts b/examples/ent-rsvp/backend/src/ent/generated/guest_base.ts index a3c5a6fc7..dd35f7bb1 100644 --- a/examples/ent-rsvp/backend/src/ent/generated/guest_base.ts +++ b/examples/ent-rsvp/backend/src/ent/generated/guest_base.ts @@ -187,11 +187,7 @@ export class GuestBase id: ID, context?: Context, ): Promise { - const row = await guestLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return guestLoader.createLoader(context).load(id); } static async loadRawDataX( diff --git a/examples/ent-rsvp/backend/src/ent/generated/guest_data_base.ts b/examples/ent-rsvp/backend/src/ent/generated/guest_data_base.ts index 25b75b954..056a9fdf3 100644 --- a/examples/ent-rsvp/backend/src/ent/generated/guest_data_base.ts +++ b/examples/ent-rsvp/backend/src/ent/generated/guest_data_base.ts @@ -171,11 +171,7 @@ export class GuestDataBase implements Ent { id: ID, context?: Context, ): Promise { - const row = await guestDataLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return guestDataLoader.createLoader(context).load(id); } static async loadRawDataX( diff --git a/examples/ent-rsvp/backend/src/ent/generated/guest_group_base.ts b/examples/ent-rsvp/backend/src/ent/generated/guest_group_base.ts index e19d06d2e..89187bd0a 100644 --- a/examples/ent-rsvp/backend/src/ent/generated/guest_group_base.ts +++ b/examples/ent-rsvp/backend/src/ent/generated/guest_group_base.ts @@ -167,11 +167,7 @@ export class GuestGroupBase implements Ent { id: ID, context?: Context, ): Promise { - const row = await guestGroupLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return guestGroupLoader.createLoader(context).load(id); } static async loadRawDataX( diff --git a/examples/ent-rsvp/backend/src/ent/generated/user_base.ts b/examples/ent-rsvp/backend/src/ent/generated/user_base.ts index d232eeb1a..f16a73831 100644 --- a/examples/ent-rsvp/backend/src/ent/generated/user_base.ts +++ b/examples/ent-rsvp/backend/src/ent/generated/user_base.ts @@ -170,11 +170,7 @@ export class UserBase implements Ent { id: ID, context?: Context, ): Promise { - const row = await userLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return userLoader.createLoader(context).load(id); } static async loadRawDataX( @@ -242,13 +238,7 @@ export class UserBase implements Ent { emailAddress: string, context?: Context, ): Promise { - const row = await userEmailAddressLoader - .createLoader(context) - .load(emailAddress); - if (!row) { - return null; - } - return row; + return userEmailAddressLoader.createLoader(context).load(emailAddress); } static loaderOptions( diff --git a/examples/simple/src/ent/generated/address_base.ts b/examples/simple/src/ent/generated/address_base.ts index 5e749f178..f563192c2 100644 --- a/examples/simple/src/ent/generated/address_base.ts +++ b/examples/simple/src/ent/generated/address_base.ts @@ -170,11 +170,7 @@ export class AddressBase implements Ent { id: ID, context?: Context, ): Promise { - const row = await addressLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return addressLoader.createLoader(context).load(id); } static async loadRawDataX( diff --git a/examples/simple/src/ent/generated/auth_code_base.ts b/examples/simple/src/ent/generated/auth_code_base.ts index 0aab5648b..e2004e4ff 100644 --- a/examples/simple/src/ent/generated/auth_code_base.ts +++ b/examples/simple/src/ent/generated/auth_code_base.ts @@ -166,11 +166,7 @@ export class AuthCodeBase implements Ent { id: ID, context?: Context, ): Promise { - const row = await authCodeLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return authCodeLoader.createLoader(context).load(id); } static async loadRawDataX( diff --git a/examples/simple/src/ent/generated/comment_base.ts b/examples/simple/src/ent/generated/comment_base.ts index 35cd508e3..5b31629e7 100644 --- a/examples/simple/src/ent/generated/comment_base.ts +++ b/examples/simple/src/ent/generated/comment_base.ts @@ -181,11 +181,7 @@ export class CommentBase implements Ent { id: ID, context?: Context, ): Promise { - const row = await commentLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return commentLoader.createLoader(context).load(id); } static async loadRawDataX( diff --git a/examples/simple/src/ent/generated/contact_base.ts b/examples/simple/src/ent/generated/contact_base.ts index 4bcb94c55..d76ca2f42 100644 --- a/examples/simple/src/ent/generated/contact_base.ts +++ b/examples/simple/src/ent/generated/contact_base.ts @@ -182,11 +182,7 @@ export class ContactBase id: ID, context?: Context, ): Promise { - const row = await contactLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return contactLoader.createLoader(context).load(id); } static async loadRawDataX( diff --git a/examples/simple/src/ent/generated/contact_email_base.ts b/examples/simple/src/ent/generated/contact_email_base.ts index 050e6f04b..d15351689 100644 --- a/examples/simple/src/ent/generated/contact_email_base.ts +++ b/examples/simple/src/ent/generated/contact_email_base.ts @@ -173,11 +173,7 @@ export class ContactEmailBase id: ID, context?: Context, ): Promise { - const row = await contactEmailLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return contactEmailLoader.createLoader(context).load(id); } static async loadRawDataX( diff --git a/examples/simple/src/ent/generated/contact_phone_number_base.ts b/examples/simple/src/ent/generated/contact_phone_number_base.ts index 9cbfaee2b..9c3d6d950 100644 --- a/examples/simple/src/ent/generated/contact_phone_number_base.ts +++ b/examples/simple/src/ent/generated/contact_phone_number_base.ts @@ -173,11 +173,7 @@ export class ContactPhoneNumberBase id: ID, context?: Context, ): Promise { - const row = await contactPhoneNumberLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return contactPhoneNumberLoader.createLoader(context).load(id); } static async loadRawDataX( diff --git a/examples/simple/src/ent/generated/event_base.ts b/examples/simple/src/ent/generated/event_base.ts index 001169f7a..0c9bd0219 100644 --- a/examples/simple/src/ent/generated/event_base.ts +++ b/examples/simple/src/ent/generated/event_base.ts @@ -197,11 +197,7 @@ export class EventBase implements Ent { id: ID, context?: Context, ): Promise { - const row = await eventLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return eventLoader.createLoader(context).load(id); } static async loadRawDataX( diff --git a/examples/simple/src/ent/generated/holiday_base.ts b/examples/simple/src/ent/generated/holiday_base.ts index 66a403299..d072df271 100644 --- a/examples/simple/src/ent/generated/holiday_base.ts +++ b/examples/simple/src/ent/generated/holiday_base.ts @@ -169,11 +169,7 @@ export class HolidayBase id: ID, context?: Context, ): Promise { - const row = await holidayLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return holidayLoader.createLoader(context).load(id); } static async loadRawDataX( diff --git a/examples/simple/src/ent/generated/hours_of_operation_base.ts b/examples/simple/src/ent/generated/hours_of_operation_base.ts index 1c01621dc..1bde56a7b 100644 --- a/examples/simple/src/ent/generated/hours_of_operation_base.ts +++ b/examples/simple/src/ent/generated/hours_of_operation_base.ts @@ -171,11 +171,7 @@ export class HoursOfOperationBase id: ID, context?: Context, ): Promise { - const row = await hoursOfOperationLoader.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return hoursOfOperationLoader.createLoader(context).load(id); } static async loadRawDataX( diff --git a/internal/tscode/base.tmpl b/internal/tscode/base.tmpl index c4c743fc6..c55bc0afb 100644 --- a/internal/tscode/base.tmpl +++ b/internal/tscode/base.tmpl @@ -341,11 +341,7 @@ implements {{useImport "Ent"}}<{{$viewerType}}> id: ID, context?: {{useImport "Context"}}, ): Promise<{{$rawDBDataType}} | null> { - const row = await {{useImport $loaderName}}.createLoader(context).load(id); - if (!row) { - return null; - } - return row; + return {{useImport $loaderName}}.createLoader(context).load(id); } static async loadRawDataX( @@ -408,11 +404,7 @@ implements {{useImport "Ent"}}<{{$viewerType}}> {{$field.TsFieldName $cfg}}: {{$field.GetNotNullableTsType}}, context?: {{useImport "Context"}}, ): Promise<{{$rawDBDataType}} | null> { - const row = await {{$fieldLoader}}.createLoader(context).load({{$field.TsFieldName $cfg}}); - if (!row) { - return null; - } - return row; + return {{$fieldLoader}}.createLoader(context).load({{$field.TsFieldName $cfg}}); } {{ else if $field.QueryFromEnt -}} {{$queryName := useImport ($this.GetFieldQueryName $field) -}}