title: Right-hand side of 'instanceof' is not an object
body: <p>I am practising nestjs in order to convert ReST API to graphql but I am getting this error whenever I try to fetch data from my GraphQL API using the playground:</p>
  <blockquote>
  <p>&quot;errors&quot;: [
  {
  &quot;message&quot;: &quot;Right-hand side of 'instanceof' is not an object&quot;,
  &quot;locations&quot;: [
  {
  &quot;line&quot;: 2,
  &quot;column&quot;: 3
  }
  ],
  &quot;path&quot;: [
  &quot;lesson&quot;
  ],
  &quot;extensions&quot;: {
  &quot;code&quot;: &quot;INTERNAL_SERVER_ERROR&quot;,
  &quot;exception&quot;: {
  &quot;stacktrace&quot;: [
  &quot;TypeError: Right-hand side of 'instanceof' is not an object&quot;,
  &quot;    at MongoEntityManager. (C:\Users\Oluyinka\Desktop\graphql-mongodb\node_modules\typeorm\entity-manager\MongoEntityManager.js:159:51)&quot;,
  &quot;    at step (C:\Users\Oluyinka\Desktop\graphql-mongodb\node_modules\tslib\tslib.js:143:27)&quot;,
  &quot;    at Object.next (C:\Users\Oluyinka\Desktop\graphql-mongodb\node_modules\tslib\tslib.js:124:57)&quot;,
  &quot;    at C:\Users\Oluyinka\Desktop\graphql-mongodb\node_modules\tslib\tslib.js:117:75&quot;,
  &quot;    at new Promise ()&quot;,
  &quot;    at Object.__awaiter (C:\Users\Oluyinka\Desktop\graphql-mongodb\node_modules\tslib\tslib.js:113:16)&quot;,
  &quot;    at MongoEntityManager.findOne (C:\Users\Oluyinka\Desktop\graphql-mongodb\node_modules\typeorm\entity-manager\MongoEntityManager.js:153:24)&quot;,
  &quot;    at MongoRepository.findOne (C:\Users\Oluyinka\Desktop\graphql-mongodb\node_modules\typeorm\repository\MongoRepository.js:57:29)&quot;,
  &quot;    at LessonService.getLesson (C:\Users\Oluyinka\Desktop\graphql-mongodb\dist\lesson\lesson.service.js:26:44)&quot;,
  &quot;    at LessonResolver.lesson (C:\Users\Oluyinka\Desktop\graphql-mongodb\dist\lesson\lesson.resolver.js:24:35)&quot;
  ]
  }
  }
  }   ],   &quot;data&quot;: null }</p>
  </blockquote>
  <p>Below is my code:</p>
  <p><strong>lesson.entity.ts</strong></p>
  <pre><code>import { Column, Entity, ObjectIdColumn, PrimaryColumn } from 'typeorm';
  
  @Entity()
  export class Lesson {
    @ObjectIdColumn()
    _id: string;
  
    @PrimaryColumn()
    id: string;
  
    @Column()
    name: string;
  
    @Column()
    startDate: string;
  
    @Column()
    endDate: string;
  }
  </code></pre>
  <p><strong>lesson.service.ts</strong></p>
  <pre><code>import { Injectable } from '@nestjs/common';
  import { InjectRepository } from '@nestjs/typeorm';
  import { Repository } from 'typeorm';
  import { Lesson } from './lesson.entity';
  import { v4 as uuid } from 'uuid';
  
  @Injectable()
  export class LessonService {
    constructor(
      @InjectRepository(Lesson) private lessonRepository: Repository&lt;Lesson&gt;,
    ) {}
  
    async getLesson(id: string): Promise&lt;Lesson&gt; {
      return await this.lessonRepository.findOne({ id });
    }
  
    async getLessons(): Promise&lt;Lesson[]&gt; {
      return this.lessonRepository.find();
    }
  
    async createLesson(name, startDate, endDate): Promise&lt;Lesson&gt; {
      const lesson = this.lessonRepository.create({
        id: uuid(),
        name,
        startDate,
        endDate,
      });
      return await this.lessonRepository.save(lesson);
    }
  }
  
  </code></pre>
  <p><strong>lesson.resolver.ts</strong></p>
  <pre><code>import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
  import { LessonService } from './lesson.service';
  import { LessonType } from './lesson.type';
  
  @Resolver((of) =&gt; LessonType)
  export class LessonResolver {
    constructor(private lessonService: LessonService) {}
    @Query((returns) =&gt; LessonType)
    lesson(@Args('id') id: string) {
      return this.lessonService.getLesson(id);
    }
  
    @Query((returns) =&gt; [LessonType])
    lessons() {
      return this.lessonService.getLessons();
    }
  
    @Mutation((returns) =&gt; LessonType)
    createLesson(
      @Args('name') name: string,
      @Args('startDate') startDate: string,
      @Args('endDate') endDate: string,
    ) {
      return this.lessonService.createLesson(name, startDate, endDate);
    }
  }
  
  </code></pre>
  <p><strong>lesson.type.ts</strong></p>
  <pre><code>import { Field, ID, ObjectType } from '@nestjs/graphql';
  
  @ObjectType('Lesson')
  export class LessonType {
    @Field((type) =&gt; ID)
    id: string;
  
    @Field()
    name: string;
  
    @Field()
    startDate: string;
  
    @Field()
    endDate: string;
  }
  </code></pre>