chkimes/graphql-net

Mutations with underlying async calls

Opened this issue · 0 comments

In the EF examples (in EntityFrameworkExecutionTests for instance), you're using context.SaveChanges() inside your "addMutate" mutation meaning your mutation parameter in the schema.AddMutation(...) signature can just be synchronous. What if you want to use context.SaveChangesAsync() though? Or, in my situation with CosmosDB, what if your underlying data storage API only has async methods?

Seems like I can add async to the mutation and await the CosmosDB call, but then I have to force blocking for .Result.
image

The queryableGetter can't be marked as async as Async lambda expressions cannot be converted into expression trees.
image
(Worth noting that using a method body won't fit anyway as it also can't be converted to an expression tree).

I get that the mutation has to happen and be waited on before the retrieval query can fire after, but I'm just wondering whether you can have overloads for AddMutation that support async?