* Resolver from `@config.getter` * @param ctx - Context object * @param injection - Injection metadata * @param session - Resolution session
( ctx: Context, injection: Injection, session: ResolutionSession, )
| 169 | * @param session - Resolution session |
| 170 | */ |
| 171 | function resolveAsGetterFromConfig( |
| 172 | ctx: Context, |
| 173 | injection: Injection, |
| 174 | session: ResolutionSession, |
| 175 | ) { |
| 176 | assertTargetType(injection, Function, 'Getter function'); |
| 177 | const bindingKey = getTargetBindingKey(injection, session); |
| 178 | const meta = injection.metadata; |
| 179 | return async function getter() { |
| 180 | // Return `undefined` if no current binding is present |
| 181 | if (!bindingKey) return undefined; |
| 182 | return ctx.getConfigAsValueOrPromise(bindingKey, meta.propertyPath, { |
| 183 | // https://github.com/loopbackio/loopback-next/issues/9041 |
| 184 | // We should start with a new session for `getter` resolution to avoid |
| 185 | // possible circular dependencies |
| 186 | session: undefined, |
| 187 | optional: meta.optional, |
| 188 | }); |
| 189 | }; |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Resolver for `@config.view` |
nothing calls this directly
no test coverage detected