You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to make the subscription update course in the nest js, but it turns out error Object is possibly 'undefined' in this line of code const course = await this.courseService.findOne({ id: variables.courseId }); below is my course.resolver.ts
@Subscription('courseUpdated', {
resolve: (value) => value,
filter: async (payload, variables) => {
const course = await this.courseService.findOne({ id: variables.courseId });
if (!course) {
throw new NotFoundException('Course not found');
}
if (course.creatorId !== variables.userId) {
throw new ForbiddenException('Course not owned by you');
}
return payload.courseId === variables.courseId;
},
})
courseUpdated(
@Args('courseId') courseId: string,
@Args('userId') userId: string,
) {
return pubSub.asyncIterator(`course:${courseId}`);
}
I read a lot on stackoverflow but still couldn't solve it. Yes indeed some of the value is optional, but how to solve it. I also tried the chaining option like this const course = await this.courseService.findOne({ id: variables.courseId })?.id; but still does not work
I tried to make the subscription update course in the nest js, but it turns out error Object is possibly 'undefined' in this line of code
const course = await this.courseService.findOne({ id: variables.courseId });
below is my course.resolver.tsHere is the piece of code in my course.graphql
I read a lot on stackoverflow but still couldn't solve it. Yes indeed some of the value is optional, but how to solve it. I also tried the chaining option like this
const course = await this.courseService.findOne({ id: variables.courseId })?.id;
but still does not workSystem:
The text was updated successfully, but these errors were encountered: