Open mscofield0 opened 3 years ago
I have a sqlite in-memory database and a PostgreSQL persistent database at the same time.
Can you try this PR and see if it works for you.
I think maybe my use case is different than the OP, but I think passing context into typeormGetConnection in ImplicitLoaderImpl would allow people like myself who want all queries for a given request to go over the same connection to be possible.
I do some initialization of connections from the pool by setting mysql connection variables, so a connection has been pulled from the pool and stored on the context. I can make all other load operations use this context connection, but since the data-loaders use the top level pool, they will 'randomly' grab another connection, which can cause issues with mysql connection TIME_ZONE, etc. I think this would be as simple as changing line 37 of ImplicitLoaderImpl.js from:
const relation = tgdContext
.typeormGetConnection()
.getMetadata(target.constructor)
.findRelationWithPropertyPath(propertyKey.toString());
to:
const relation = tgdContext
.typeormGetConnection(context)
.getMetadata(target.constructor)
.findRelationWithPropertyPath(propertyKey.toString());
This would give a program access to any context-specific information/connections/etc when handling the loading operations for a given request.
What kind of use cases do you assume?