graphql-workshop
graphql-workshop copied to clipboard
"There was no argument with the name `speaker` found on the field `sessions`."
When completing section 3 "Understanding Dataloaders", with the introduction of SpeakerType, and SpeakerResolvers, I'm getting the error:
{
"errors": [
{
"message": "There was no argument with the name `speaker` found on the field `sessions`.",
"locations": [
{
"line": 5,
"column": 6
}
],
"path": [
"speakers",
0,
"sessions"
],
"extensions": {
"fieldName": "sessions",
"argumentName": "speaker"
}
}
]
}
`private class SpeakerResolvers
{
public async Task<IEnumerable<Session>> GetSessionAsync(
[Parent]Speaker speaker,
[ScopedService]ApplicationDbContext dbContext,
SessionByIdDataLoader sessionByIdDataLoader,
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(cancellationToken);
return await sessionByIdDataLoader.LoadAsync(sessionIds, cancellationToken);
}
}`
marking the first parameter with the Parent attribute solved it for me. specified in v11 to v12 the upgrade guide https://chillicream.com/docs/hotchocolate/api-reference/migrate-from-11-to-12#resolvers
Should be mentioned in the workshop I think. Had the same problem today and took me some time to figure it out. I see that other people also encountered this issue.
Thanks for posting this, wasted a little bit of time on it.