static void Main() { var schema = GraphQL <TestContext> .CreateDefaultSchema(() => new TestContext()); schema.AddType <User>() .AddField(u => u.Id) .AddField(u => u.Name) .AddField(u => u.Account) .AddField("total", (db, u) => db.Users.Count()) .AddField("accountPaid", (db, u) => u.Account.Paid); schema.AddQuery("users", db => db.Users); schema.AddQuery("user", new { id = 0 }, (db, args) => db.Users.Where(u => u.Id == args.id).FirstOrDefault()); //schema.AddType<Account>().AddAllFields(); // TODO: schema.AddType <Account>() .AddField(a => a.Id) .AddField(a => a.Name) .AddField(a => a.Paid); //Initialize(); var queryStr1 = @" query user(id:1) { idAlias : id, nameAlias : name, account { id }, total }"; var queryStr2 = @" query user(id:0) { idAlias : id, nameAlias : name, account { id } }"; var queryStr3 = @" query users { idAlias : id, nameAlias : name, account { id } total accountPaid }"; var dict = GraphQL <TestContext> .Execute(queryStr1); Console.WriteLine(JsonConvert.SerializeObject(dict, Formatting.Indented)); dict = GraphQL <TestContext> .Execute(queryStr2); Console.WriteLine(JsonConvert.SerializeObject(dict, Formatting.Indented)); dict = GraphQL <TestContext> .Execute(queryStr3); Console.WriteLine(JsonConvert.SerializeObject(dict, Formatting.Indented)); Console.ReadLine(); }