import { Context, Parent, ResolveField, Resolver } from '@nestjs/graphql';
import { Apparatus } from '../models/Apparatus';
import { Client } from '../../client';
import { UUID } from '../../global/scalars/UUID';

@Resolver(() => Apparatus)
export class ApparatusResolver {
  @ResolveField(() => UUID, { nullable: false })
  async _id(
    @Context('client') client: Client,
    @Parent() parent: Apparatus
  ): Promise<UUID> {
    return parent._id as UUID;
  }

  @ResolveField(() => String, { nullable: false })
  async name(
    @Context('client') client: Client,
    @Parent() parent: Apparatus
  ): Promise<string> {
    return parent.name;
  }

  @ResolveField(() => String, { nullable: true })
  async logo(
    @Context('client') client: Client,
    @Parent() parent: Apparatus
  ): Promise<string> {
    return parent.logo;
  }
}