import { Parent, ResolveField, Resolver } from '@nestjs/graphql';

import { AnomalyService } from '../feat-business-objects/entities/anomaly/anomaly.service';
import {
  SolutionTargetObjectType,
  SolutionTargetStepObjectType,
} from './anomaly.object-type';

@Resolver(() => SolutionTargetObjectType)
export class SolutionTargetsResolver {
  constructor(private readonly anomalyService: AnomalyService) {}

  @ResolveField(() => [SolutionTargetStepObjectType!]!)
  steps(
    @Parent() solutionTarget: SolutionTargetObjectType,
  ): Promise<SolutionTargetStepObjectType[]> {
    return this.anomalyService.findSolutionTargetStepsBySolutionTargetId(
      solutionTarget.id,
    );
  }
}
