title: Unable to resolve service for type 'GraphQL.Http.IDocumentWriter'
body: <p>I used following only controller in my project out of entire following project.</p>
  
  <p><a href="https://github.com/graphql-dotnet/examples/blob/master/src/AspNetWebApi/Example/Controllers/GraphQLController.cs" rel="nofollow noreferrer">https://github.com/graphql-dotnet/examples/blob/master/src/AspNetWebApi/Example/Controllers/GraphQLController.cs</a></p>
  
  <p>Here Controller file is as below.</p>
  
  <pre><code>using System.Collections.Generic;
  using System.Net;
  using System.Net.Http;
  using System.Text;
  using System.Threading.Tasks;
  using System.Web.Http;
  using GraphQL.Http;
  using GraphQL.Instrumentation;
  using GraphQL.Types;
  using GraphQL.Validation.Complexity;
  
  namespace GraphQL.GraphiQL.Controllers
  {
      public class GraphQLController : ApiController
      {
          private readonly ISchema _schema;
          private readonly IDocumentExecuter _executer;
          private readonly IDocumentWriter _writer;
          private readonly IDictionary&lt;string, string&gt; _namedQueries;
  
          public GraphQLController(
              IDocumentExecuter executer,
              IDocumentWriter writer,
              ISchema schema)
          {
              _executer = executer;
              _writer = writer;
              _schema = schema;
  
              _namedQueries = new Dictionary&lt;string, string&gt;
              {
                  ["a-query"] = @"query foo { hero { name } }"
              };
          }
  
          // This will display an example error
          [HttpGet]
          public Task&lt;HttpResponseMessage&gt; GetAsync(HttpRequestMessage request)
          {
              return PostAsync(request, new GraphQLQuery { Query = "query foo { hero }", Variables = null });
          }
  
          [HttpPost]
          public async Task&lt;HttpResponseMessage&gt; PostAsync(HttpRequestMessage request, GraphQLQuery query)
          {
              var inputs = query.Variables.ToInputs();
              var queryToExecute = query.Query;
  
              if (!string.IsNullOrWhiteSpace(query.NamedQuery))
              {
                  queryToExecute = _namedQueries[query.NamedQuery];
              }
  
              var result = await _executer.ExecuteAsync(_ =&gt;
              {
                  _.Schema = _schema;
                  _.Query = queryToExecute;
                  _.OperationName = query.OperationName;
                  _.Inputs = inputs;
  
                  _.ComplexityConfiguration = new ComplexityConfiguration { MaxDepth = 15 };
                  _.FieldMiddleware.Use&lt;InstrumentFieldsMiddleware&gt;();
  
              }).ConfigureAwait(false);
  
              var httpResult = result.Errors?.Count &gt; 0
                  ? HttpStatusCode.BadRequest
                  : HttpStatusCode.OK;
  
              var json = _writer.Write(result);
  
              var response = request.CreateResponse(httpResult);
              response.Content = new StringContent(json, Encoding.UTF8, "application/json");
  
              return response;
          }
      }
  
      public class GraphQLQuery
      {
          public string OperationName { get; set; }
          public string NamedQuery { get; set; }
          public string Query { get; set; }
          public Newtonsoft.Json.Linq.JObject Variables { get; set; }
      }
  }
  </code></pre>
  
  <p>When I try to call this controller, it gives me following error. </p>
  
  <pre><code>InvalidOperationException: Unable to resolve service for type 'GraphQL.Http.IDocumentWriter' while attempting to activate 'MyWebAppNamespace.Controllers.GraphQLController'.
  </code></pre>
  
  <p>Do I need any startup configuration or I can use this standalone controller? What am I missing?</p>