Upon updating TypeORM from version 0.2.37 to 0.3.12, I encountered an issue where the where statement stopped returning any answers' entity, even though there are relevant records in the database (the question is unable to find any answer). Reverting back to version 0.2.37 fixed the problem.
I am curious about what might be causing this behavior specifically in TypeORM version 0.3.12. Is there a way to address this issue while continuing to use the latest version of TypeORM?
Below is the code snippet for reference:
📁resolvers/📁types/📄question.ts
import {
Ctx,
FieldResolver,
Resolver,
ResolverInterface,
Root,
} from "type-graphql";
import { Context } from "./../../index"
import { Answer } from "../../entities/answer";
import { Question } from "../../entities/question";
import { Posted_Answer } from "../../entities/posted_answer";
@Resolver((of) => Question)
export class Question_Resolver implements ResolverInterface<Question> {
@FieldResolver()
async answers(@Root() root: Question, @Ctx() context: Context) {
const answers = await context.connection.manager.find(Answer, {
// Removing the where statement allows question to resolve answers with TypeORM 0.3.12, but filtering is necessary.
where: { question: root },
});
return answers;
}
}