1010using Newtonsoft . Json . Linq ;
1111using Npgsql ;
1212using System ;
13+ using System . Collections . Generic ;
1314using System . Data ;
1415using System . Linq ;
1516using System . Reflection ;
@@ -96,6 +97,21 @@ public async Task<string> QueryGraphQLAsync(string query)
9697 return json ;
9798 }
9899
100+ public async Task < string > QueryGraphQLAsync ( GraphQlQuery query )
101+ {
102+ var result = await DocumentExecuter
103+ . ExecuteAsync ( options =>
104+ {
105+ options . Schema = Schema ;
106+ options . Query = query . Query ;
107+ options . Inputs = query . Variables != null ? new Inputs ( StringExtensions . GetValue ( query . Variables ) as Dictionary < string , object > ) : null ;
108+ } )
109+ . ConfigureAwait ( false ) ;
110+
111+ var json = new DocumentWriter ( indent : true ) . Write ( result ) ;
112+ return json ;
113+ }
114+
99115 public void SetupDatabaseConnection ( )
100116 {
101117 // Generate a random db name
@@ -148,6 +164,8 @@ FROM pg_stat_activity
148164
149165 private void SetupDapperGraphQL ( IServiceCollection serviceCollection )
150166 {
167+ serviceCollection . AddSingleton < IDependencyResolver > ( s => new FuncDependencyResolver ( s . GetRequiredService ) ) ;
168+
151169 serviceCollection . AddDapperGraphQL ( options =>
152170 {
153171 // Add GraphQL types
@@ -156,6 +174,8 @@ private void SetupDapperGraphQL(IServiceCollection serviceCollection)
156174 options . AddType < PersonType > ( ) ;
157175 options . AddType < GraphQL . PhoneType > ( ) ;
158176 options . AddType < PersonQuery > ( ) ;
177+ options . AddType < PersonMutation > ( ) ;
178+ options . AddType < PersonInputType > ( ) ;
159179
160180 // Add the GraphQL schema
161181 options . AddSchema < PersonSchema > ( ) ;
0 commit comments