Closed weirdyang closed 1 year ago
public class SpeakerType : ObjectType<Speaker> { protected override void Configure(IObjectTypeDescriptor<Speaker> descriptor) { descriptor .Field(t => t.SessionSpeakers) .ResolveWith<SpeakerResolvers>(t => t.GetSessionsAsync(default!, default!, default!, default)) .UseDbContext<ApplicationDbContext>() .Name("sessions"); } private class SpeakerResolvers { public async Task<IEnumerable<Session>> GetSessionsAsync( Speaker speaker, ApplicationDbContext dbContext, SessionByIdDataLoader sessionById, CancellationToken cancellationToken) { int[] sessionIds = await dbContext.Speakers .Where(s => s.Id == speaker.Id) .Include(s => s.SessionSpeakers) .SelectMany(s => s.SessionSpeakers.Select(t => t.SessionId)) .ToArrayAsync(); return await sessionById.LoadAsync(sessionIds, cancellationToken); } } }
builder.Services .AddGraphQLServer() .RegisterDbContext<ApplicationDbContext>(DbContextKind.Pooled) .AddQueryType<Query>() .AddMutationType<SpeakerMutation>() .AddType<SpeakerType>() .AddDataLoader<SpeakerByIdDataLoader>() .AddDataLoader<SessionByIdDataLoader>();
I've updated the speaker model, added the speakerType, ran the migration and updated the database, however the schema in the browser still does not show the SessionSpeakers collection. Has there been any changes between the versions?
SessionSpeakers
sorry realised it was renamed to sessions
I've updated the speaker model, added the speakerType, ran the migration and updated the database, however the schema in the browser still does not show the
SessionSpeakers
collection. Has there been any changes between the versions?