title: How do you define a GraphQL host type using a code-first field resolver?
body: <p>I am using NestJS with TypeORM to connect with a MongoDB server running on a docker image. I am getting this error when trying to start the application:</p>
  <pre><code>type-metadata.storage.js:263
              throw new cannot_determine_host_type_error_1.CannotDetermineHostTypeError(item.schemaName, objectTypeRef === null || objectTypeRef === void 0 ? void 0 : objectTypeRef.name);
                    ^
  Error: Cannot determine a GraphQL host type  (CreateClassInput?) for the &quot;students&quot; field. Make sure your class is decorated with an appropriate decorator (e.g., @ObjectType()).
      at TypeMetadataStorageHost.compileExternalFieldResolverMetadata
  </code></pre>
  <p>The field resolver is for a field named <code>students</code>. <code>Students</code> is an array of <code>StudentOutput</code> objects. The parent of <code>students</code> is defined in a GraphQL <code>@ObjectType()</code> class named <code>ClassOutput</code>:</p>
  <pre><code>@ObjectType()
  export class ClassOutput extends PartialType(UpdateClassInput) {
    @IsUUID('4', { each: true })
    @Field(() =&gt; String)
    class_id: string;
  
    @Field(() =&gt; [StudentOutput], { defaultValue: [] })
    students: StudentOutput[];
  </code></pre>
  <p>The resolver properly lists <code>ClassOutput</code> as the parent GraphQL type for the <code>students</code> field.</p>
  <pre><code>@ResolveField()
    students(@Parent() classGQLObject: ClassOutput): Promise&lt;StudentOutput[]&gt; {
      return this.studentsService.findStudentsByIDArray(classGQLObject);
    }
  </code></pre>
  <p>Changing the decorator of <code>ClassOutput</code> from <code>@ObjectType()</code> to <code>@InputType()</code> did not resolve the error. This is how the `students field is defined in the TypeORM entity class:</p>
  <pre><code>@Entity('classes')
  export class ClassesEntity {
    @ObjectIdColumn()
    _id: ObjectID;
  
    @PrimaryColumn()
    class_id: string;
  
    @Column({ type: 'array', default: [] })
    students: StudentOutput[];
  </code></pre>
  <p>Why is GraphQL unable to find the parent type of <code>students</code> when the parent type is defined in the resolver function thru <code>students(@Parent() classGQLObject: ClassOutput)</code>, the decorated GraphQL class<code>ClassOutput</code>, and the entity?</p>