title: Custom map keys in GraphQL response
body: <p>I've been looking into GraphQL as a replacement for some REST APIs of mine, and while I think I've wrapped my head around the basics and like most of what I see so far, there's one important feature that seems to be missing.</p>
  
  <p>Let's say I've got a collection of items like this:</p>
  
  <pre><code>{
      "id": "aaa",
      "name": "Item 1",
      ...
  }
  </code></pre>
  
  <p>An application needs a map of all those objects, indexed by ID as such:</p>
  
  <pre><code>{
      "allItems": {
          "aaa": {
              "name": "Item 1",
              ...
          },
          "aab": {
              "name": "Item 2",
              ...
          }
      }
  }
  </code></pre>
  
  <p>Every API I've ever written has been able to give results back in a format like this, but I'm struggling to find a way to do it with GraphQL. I keep running across <a href="https://github.com/facebook/graphql/issues/101" rel="noreferrer">issue 101</a>, but that deals more with unknown schemas. In my case, I know exactly what all the fields are; this is purely about output format. I know I could simply return all the items in an array and reformat it client-side, but that seems like overkill given that it's never been needed in the past, and would make GraphQL feel like a step backwards. I'm not sure if what I'm trying to do is impossible, or I'm just using all the wrong terminology. Should I keep digging, or is GraphQL just not suited to my needs? If this is possible, what might a query look like to retrieve data like this?</p>
  
  <p>I'm currently working with <a href="https://github.com/webonyx/graphql-php" rel="noreferrer">graphql-php</a> on the server, but I'm open to higher-level conceptual responses.</p>