MCPcopy
hub / github.com/loopbackio/loopback-next / getResolutionContext

Method getResolutionContext

packages/context/src/context.ts:530–560  ·  view source on GitHub ↗

* Locate the resolution context for the given binding. Only bindings in the * resolution context and its ancestors are visible as dependencies to resolve * the given binding * @param binding - Binding object

(
    binding: Readonly<Binding<unknown>>,
  )

Source from the content-addressed store, hash-verified

528 * @param binding - Binding object
529 */
530 getResolutionContext(
531 binding: Readonly<Binding<unknown>>,
532 ): Context | undefined {
533 let resolutionCtx: Context | undefined;
534 switch (binding.scope) {
535 case BindingScope.SINGLETON:
536 // Use the owner context
537 return this.getOwnerContext(binding.key);
538 case BindingScope.TRANSIENT:
539 case BindingScope.CONTEXT:
540 // Use the current context
541 return this;
542 case BindingScope.REQUEST:
543 resolutionCtx = this.getScopedContext(binding.scope);
544 if (resolutionCtx != null) {
545 return resolutionCtx;
546 } else {
547 // If no `REQUEST` scope exists in the chain, fall back to the current
548 // context
549 this.debug(
550 'No context is found for binding "%s (scope=%s)". Fall back to the current context.',
551 binding.key,
552 binding.scope,
553 );
554 return this;
555 }
556 default:
557 // Use the scoped context
558 return this.getScopedContext(binding.scope);
559 }
560 }
561
562 /**
563 * Check if this context is visible (same or ancestor) to the given one

Callers

nothing calls this directly

Calls 3

getOwnerContextMethod · 0.95
getScopedContextMethod · 0.95
debugMethod · 0.95

Tested by

no test coverage detected