Closed filipgoris closed 2 years ago
The documentation needs to be corrected. The documentation is using Hot Chocolate 11 guidelines, but failed to add the resolver requires a parent attribute now.
Open up your SpeakerType
file and update the resolver signature as such:
private class SpeakerResolvers
{
public async Task<IEnumerable<Session>> GetSessionsAsync(
[Parent] Speaker speaker, // Requires the [Parent] attribute.
[ScopedService] 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);
}
}
More info can be found [https://chillicream.com/docs/hotchocolate/api-reference/migrate-from-11-to-12#resolvers?ref=https://githubhelp.com](here)
Perfect. That was it!
Following the docs until the explanation of [Fluent Type Configurations on page 3-understanding-dataLoader.md] (https://github.com/ChilliCream/graphql-workshop/blob/master/docs/3-understanding-dataLoader.md#fluent-type-configurations).
Executing query
query GetSpeakerWithSessions { speakers { name sessions { title } } }
Should produce list of speakers with empty sessions list
Produces instead "There was no argument with the name
speaker
found on the fieldsessions
." for each speaker on line 4 column 5 of the query.