Closed Dastari closed 5 years ago
Hi! Does the issue persist if you load the data using TypeORM directly? It sounds more like a TypeORM connection issue.
This could be related, by the way: tediousjs/tedious#458
Hi! Does the issue persist if you load the data using TypeORM directly? It sounds more like a TypeORM connection issue.
This could be related, by the way: tediousjs/tedious#458
It does work loading data using TypeORM directly.
I think the issue may be related to TypeORM still using the connection when using the loader directly in the entity @Field. If I move the loader into a @FieldResolver in the @Resolver the issue goes away.
What happens if you do something like this?
@Field(() => [Job])
async AssignedJobs(
@Ctx() { loader }: BaseContext,
): Promise<Job[]> {
return new Promise((resolve, reject) => {
setTimeout(() => loader.loadMany(Job, { NameNo: this.CardNo }).then(resolve, reject), 0);
});
}
Assuming this resolved because there was not response.
I get the following error whenever I use any of the load functions:
error: { RequestError: Requests can only be made in the LoggedIn state, not the SentClientRequest state at Request.tds.Request.err [as userCallback] (C:\Dev\gema\api\node_modules\mssql\lib\tedious.js:614:19) at Request._this.callback (C:\Dev\gema\api\node_modules\tedious\lib\request.js:61:27) at Connection.makeRequest (C:\Dev\gema\api\node_modules\tedious\lib\connection.js:1606:17) at Connection.execSql (C:\Dev\gema\api\node_modules\tedious\lib\connection.js:1369:12) at Immediate.parent.acquire [as _onImmediate] (C:\Dev\gema\api\node_modules\mssql\lib\tedious.js:838:63) at runCallback (timers.js:697:11) at tryOnImmediate (timers.js:667:5) at processImmediate (timers.js:649:5) at process.topLevelDomainCallback (domain.js:121:23) code: 'EINVALIDSTATE', number: 'EINVALIDSTATE', state: undefined, originalError: { RequestError: Requests can only be made in the LoggedIn state, not the SentClientRequest state at RequestError (C:\Dev\gema\api\node_modules\tedious\lib\errors.js:34:12) at Connection.makeRequest (C:\Dev\gema\api\node_modules\tedious\lib\connection.js:1606:26) at Connection.execSql (C:\Dev\gema\api\node_modules\tedious\lib\connection.js:1369:12) at Immediate.parent.acquire [as _onImmediate] (C:\Dev\gema\api\node_modules\mssql\lib\tedious.js:838:63) at runCallback (timers.js:697:11) at tryOnImmediate (timers.js:667:5) at processImmediate (timers.js:649:5) at process.topLevelDomainCallback (domain.js:121:23) message: 'Requests can only be made in the LoggedIn state, not the SentClientRequest state', code: 'EINVALIDSTATE' }, name: 'RequestError', precedingErrors: [] } query: COMMIT
index.js
Then in my Entity:
Any thoughts? Is this a unique issue with using the mssql driver?