note: using 0.6.0
given this constructor
@singleton()
export default class App {
constructor(
private readonly apolloServerConfig: ApolloServerConfig,
@optional(InjectToken.GraphHost) private readonly host: string = '0.0.0.0',
@optional(InjectToken.GraphPort) private readonly port: number = 4000,
@inject(InjectToken.CorsOrigins) private readonly origins: string,
@inject(LoggerDefault) private readonly log: Logger,
) {}
and
@singleton()
export default class ApolloServerConfig implements Config {
constructor(
@all(InjectToken.GraphFieldResolvers)
private readonly graphResolvers: Array<ResolversFactory>,
@inject(InjectToken.EngineApiKey)
private readonly engineApiKey: string,
@inject(InjectToken.GraphApiKey)
private readonly serviceApiKey: string,
@inject(InjectToken.GraphSkipApiKey)
private readonly skipApiKey: string,
) {}
when I call container.get(App)
I get this
error: uncaughtException: Code 5
Error: Code 5
at Object.error (/Users/calebcushing/IdeaProjects/service-graph/node_modules/@aurelia/kernel/src/reporter.ts:58:61)
at validateKey (/Users/calebcushing/IdeaProjects/service-graph/node_modules/@aurelia/kernel/src/di.ts:1012:20)
at Container.get (/Users/calebcushing/IdeaProjects/service-graph/node_modules/@aurelia/kernel/src/di.ts:845:5)
at Object.invoke (/Users/calebcushing/IdeaProjects/service-graph/node_modules/@aurelia/kernel/src/di.ts:630:21)
at Factory.construct (/Users/calebcushing/IdeaProjects/service-graph/node_modules/@aurelia/kernel/src/di.ts:540:22)
at Resolver.resolve (/Users/calebcushing/IdeaProjects/service-graph/node_modules/@aurelia/kernel/src/di.ts:476:37)
at Container.get (/Users/calebcushing/IdeaProjects/service-graph/node_modules/@aurelia/kernel/src/di.ts:860:27)
at Object.<anonymous> (/Users/calebcushing/IdeaProjects/service-graph/src/index.ts:18:6)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Module.m._compile (/Users/calebcushing/IdeaProjects/service-graph/node_modules/ts-node/src/index.ts:473:23)
at Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Object.require.extensions.<computed> [as .ts] (/Users/calebcushing/IdeaProjects/service-graph/node_modules/ts-node/src/index.ts:476:12)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11
on the pro side, the failing line number is in there, on the conn side, this didn’t have a helpful message at all. Turns out after much digging it wasn’t finding the key for the first parameter apolloServerConfig
. What would be helpful here is to include the “parent” object that dependencies are trying to be resolved for, and if possible which position is failing.
When I added @Inject(ApolloServerConfig)
to that it works fine, but I thought I shouldn’t need inject on managed types? Perhaps since I’m just using the @aurelia/kernel
there is something more I need to do to make the magic happen?