chkimes / graphql-net

Convert GraphQL to IQueryable
MIT License
891 stars 86 forks source link

Mutations with underlying async calls #90

Open benmccallum opened 6 years ago

benmccallum commented 6 years ago

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?