namespace Adapters.Driving.Api.Types.Subjects;

using Adapters.Driven.Persistence.DataLoaders;
using Domain.Entities;

[ObjectType<Subject>]
public static partial class SubjectType
{
    [GraphQLDescription("Professor teaching this subject")]
    public static async Task<Professor?> GetProfessor(
        [Parent] Subject subject,
        ProfessorByIdDataLoader dataLoader,
        CancellationToken ct) =>
        await dataLoader.LoadAsync(subject.ProfessorId, ct);
}
