Skip to content

whyseco/ReproHotChocolateIssueAsyncEF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Repro HotChocolate issue async/await and EF

https://stackoverflow.com/questions/66875998/hotchocolate-resolve-and-async

Getting started

cd Demo dotnet watch run

on localhost:5001/graphql

launch request :

query {
  user(id:1) {
    id
    notesOne {
      id
      note
    }
    notesTwo {
      id
      note
    }
  }
}

and experience System.InvalidOperationException: A second operation was started on this context before a previous operation completed

Temporary workaround

Do not use async/await and force sync execution

# in UserType.cs

//descriptor.Field("notesOne").UseDbContext<DemoContext>().Resolve(async _ => await GetNotes(_.Parent<User>())).Type(typeof(List<UserNote>));
descriptor.Field("notesOne").UseDbContext<DemoContext>().Resolve(_ => GetNotes(_.Parent<User>()).Result).Type(typeof(List<UserNote>));

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published