Skip to content

Commit 292205e

Browse files
committed
Alias public neo4j hydrate method as different name
This strategy will allow the edgedb version to be fully type safe with the neo4j version. Using a stubbed method is better because we know it won't be called, and this makes the types happy and easier.
1 parent 8ba135b commit 292205e

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

src/components/project/project-member/project-member.repository.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ export class ProjectMemberRepository extends DtoRepository<
117117
node('user', 'User'),
118118
])
119119
.subQuery('user', (sub) =>
120-
sub.with('user as node').apply(this.users.hydrate(session.userId)),
120+
sub
121+
.with('user as node')
122+
.apply(this.users.hydrateAsNeo4j(session.userId)),
121123
)
122124
.return<{ dto: UnsecuredDto<ProjectMember> }>(
123125
merge('props', { user: 'dto' }).as('dto'),

src/components/user/user.edgedb.repository.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,7 @@ import type { UserRepository } from './user.repository';
1212
@Injectable()
1313
export class UserEdgeDBRepository
1414
extends RepoFor(User).withDefaults()
15-
implements
16-
Omit<
17-
PublicOf<UserRepository>,
18-
// hydrate is public (not default) and specific to Neo4j,
19-
// but it will only be called by other neo4j repositories,
20-
// so it doesn't have to match here
21-
'hydrate'
22-
>
15+
implements PublicOf<UserRepository>
2316
{
2417
async doesEmailAddressExist(email: string) {
2518
const query = e.select(e.User, () => ({
@@ -43,4 +36,8 @@ export class UserEdgeDBRepository
4336
removeOrganizationFromUser(args: RemoveOrganizationFromUser): Promise<void> {
4437
throw new NotImplementedException().with(args);
4538
}
39+
40+
hydrateAsNeo4j(_session: unknown): any {
41+
throw new NotImplementedException();
42+
}
4643
}

src/components/user/user.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { UserService } from './user.service';
3636
AssignableRolesResolver,
3737
UserLoader,
3838
UserService,
39-
splitDb(UserRepository, UserEdgeDBRepository as any),
39+
splitDb(UserRepository, UserEdgeDBRepository),
4040
KnownLanguageRepository,
4141
],
4242
exports: [UserService, UserRepository, EducationModule, UnavailabilityModule],

src/components/user/user.repository.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class UserRepository extends DtoRepository<typeof User, [Session | ID]>(
104104
return undefined;
105105
}
106106

107-
hydrate(requestingUserId: Session | ID) {
107+
protected hydrate(requestingUserId: Session | ID) {
108108
return (query: Query) =>
109109
query
110110
.subQuery('node', (sub) =>
@@ -347,4 +347,8 @@ export class UserRepository extends DtoRepository<typeof User, [Session | ID]>(
347347
await removePrimary.first();
348348
}
349349
}
350+
351+
hydrateAsNeo4j(session: Session | ID) {
352+
return this.hydrate(session);
353+
}
350354
}

0 commit comments

Comments
 (0)