graphql-workshop
graphql-workshop copied to clipboard
RenameSession Error
Hi! I want to try the get started found here: https://chillicream.com/docs/strawberryshake/get-started and the following project is generated. I found that the RenameSession is not work correctly after click the Save button. The problem occurred in the graphql server .
The error msg as follows: https://files.slack.com/files-pri/TD98NH6TS-F02RX8AQ5FZ/image.png https://files.slack.com/files-pri/TD98NH6TS-F02RVR6BTEK/image.png
And the function should be modified as follows:
[UseApplicationDbContext]
public async Task<RenameSessionPayload> RenameSessionAsync(
RenameSessionInput input,
[ScopedService] ApplicationDbContext context,
[Service]ITopicEventSender eventSender)
{
var session = await context.Sessions.FindAsync( int.Parse( input.SessionId));
if (session is null)
{
return new RenameSessionPayload(
new UserError("Session not found.", "SESSION_NOT_FOUND"));
}
session.Title = input.Title;
await context.SaveChangesAsync();
await eventSender.SendAsync(
nameof(SessionSubscriptions.OnSessionScheduledAsync),
session.Id);
return new RenameSessionPayload(session);
}