|
1 |
| -import { Inject, Injectable, type Type } from '@nestjs/common'; |
| 1 | +import { Injectable, type Type } from '@nestjs/common'; |
2 | 2 | import {
|
3 | 3 | DataLoaderContext,
|
4 | 4 | type DataLoaderStrategy,
|
5 | 5 | } from '@seedcompany/data-loader';
|
6 | 6 | import type { ConditionalKeys, Merge, ValueOf } from 'type-fest';
|
7 | 7 | import { type ID, type Many, type ObjectView, ServerException } from '~/common';
|
8 |
| -import type { AuthenticationService } from '../../components/authentication'; |
| 8 | +import { Identity } from '../authentication'; |
9 | 9 | import { ConfigService } from '../config/config.service';
|
10 | 10 | import { type BaseNode } from '../database/results';
|
11 | 11 | import { GqlContextHost } from '../graphql';
|
@@ -44,7 +44,7 @@ export class ResourceLoader {
|
44 | 44 | private readonly loaderRegistry: ResourceLoaderRegistry,
|
45 | 45 | private readonly contextHost: GqlContextHost,
|
46 | 46 | private readonly config: ConfigService,
|
47 |
| - @Inject('AUTHENTICATION') private readonly auth: AuthenticationService & {}, |
| 47 | + private readonly identity: Identity, |
48 | 48 | private readonly loaderContext: DataLoaderContext,
|
49 | 49 | private readonly resourceResolver: ResourceResolver,
|
50 | 50 | ) {}
|
@@ -111,13 +111,12 @@ export class ResourceLoader {
|
111 | 111 | type: Type<DataLoaderStrategy<T, Key, CachedKey>>,
|
112 | 112 | ) {
|
113 | 113 | if (this.config.isCli) {
|
114 |
| - // Ensure the default root session is ready to go for data loaders |
115 |
| - await this.auth.lazySessionForRootUser(); |
| 114 | + await this.identity.readyForCli(); |
116 | 115 | }
|
117 |
| - return await this.loaderContext.getLoader<T, Key, CachedKey>( |
118 |
| - type, |
119 |
| - this.config.isCli ? CLI_CONTEXT_ID : this.contextHost.context, |
120 |
| - ); |
| 116 | + const context = this.config.isCli |
| 117 | + ? CLI_CONTEXT_ID |
| 118 | + : this.contextHost.context; |
| 119 | + return await this.loaderContext.getLoader<T, Key, CachedKey>(type, context); |
121 | 120 | }
|
122 | 121 |
|
123 | 122 | private findLoaderFactory(type: Many<keyof ResourceMap | SomeResourceType>) {
|
|
0 commit comments