title: Implementing GraphQL in .NET Core 2.0 WebApi
body: <p>I was wondering if you could help me out with GraphQL and .NET Asp.Net WebAPI  please.</p>
  
  <p>I currently have this scenario where I have a .NET Core 2.0 WebApi project and uses Postgresql as a database backend. (See implementation below).</p>
  
  <p><em>Client Implementation:</em></p>
  
  <pre><code>public class Client {
     public long Id { get; set; }
     public Name Name { get; set; }
     public long Id { get; set; }
     public string Email { get; set; }
     public IEnumerable&lt;Paper&gt; Papers { get; set;}
  }
  
  public class Name {
     public string First {get; set;}
     public string Middle {get; set;}
     public string Last {get; set;}
  }
  
  public class Paper {
     public long Id { get; set; }
     public string Content { get; set; }
     public string Title { get; set; }
  }
  
  public class ClientService
  {
      public IMyRepository _clients;
  
      public ClientService(IMyRepository client) {
          _clients = client;
      }
  
      public IEnumerable&lt;Client&gt; GetClients()
      {
          return _clients.GetAllClients();
      }
  
      public IEnumerable&lt;Client&gt; Search(long id) {
          return _clients.GetById(id);
      }
  
      public IEnumerable&lt;Client&gt; SearchByEmail(string email) {
          return _clients.GetById(id);
      }
  
      public IEnumerable&lt;Client&gt; SearchPapers(string title) {
          return _clients.GetClientsWithPaperTitle(title);
      }
  
      // and any other searches I want to implement based on Client and Paper classes
  }
  
  
  public class ClientController: Controller
  {
      private ClientService _service;
  
      public ClientController(ClientService service) {
          _service = service;
      }
  
      public IActionResult Get() {
          var records = _service.GetClients();
          return new JsonResult(records);
      }
  
      // This is where I'm getting stuck
      public IActionResult Search(string value) {
          var records = _service.GetClients();
          return new JsonResult(records);
      }
  }
  
  public class Query {
      private ClientService _service;
  
      [GraphQLMetadata("client")]
      public async Task&lt;IClient&gt; GetClient()
      {
          return _service.GetClients();
      }
  
      [GraphQLMetadata("client")]
      public async Task&lt;IClient&gt; GetClient(string email, long id, long paperId, string paperTitle)
      {
          return _service.GetClients();
      }
  
  
  }
  </code></pre>
  
  <p>I am thinking of providing a single endpoint where I want the webapi client consumer to provide the filters one needs based on a predefined, expected class object. </p>
  
  <p>Given that GraphQL has the ability to expose a query-like function, do GraphQL have the ability to do complex WHERE clauses where I could pass a filter object similar to this?</p>
  
  <p>If using the query GetClient(email: "test@email.com")   </p>
  
  <pre><code> {
          client(email: "test@email.com, paper: "MyPaperTitle", range.paperId (1,5) {
              Id
              Name
              Email
              Papers {
                  Title
                  Content
              }
          }
     }
  </code></pre>
  
  <p>Which is an equivalent Postgresql query of   </p>
  
  <pre><code>SELECT *
     FROM 
          client
          inner join papers on client.Id = Papers.ClientId
      WHERE
          Email = 'test@email.com'
          and papers.title LIKE 'MyTitle%'
          and papers.id  between 1 and 5
      ;
  </code></pre>
  
  <p>Or: </p>
  
  <pre><code> {
          client(email: "test@email.com) {
              Id
              Name
              Email
              Papers (paper: "MyPaperTitle") {
                  Title
                  Content
              }
          }
     }
  </code></pre>
  
  <p>Which is an equivalent Postgresql query of    </p>
  
  <pre><code>SELECT *
     FROM 
          client
          inner join papers on client.Id = Papers.ClientId
      WHERE
          Email = 'test@email.com'
          and papers.title LIKE 'MyTitle%'
      ;
  </code></pre>
  
  <p>Would really appreciate any help/advice on this.</p>
  
  <p>Many thanks,
  Ann</p>