title: How to use object as keys in an elegant hash-style way
body: <p>I have the following code:</p>
  <pre class="lang-js prettyprint-override"><code>const { query1 } = require('query1')
  const { query2 } = require('query2')
  const { query3 } = require('query3')
  
  const schema = new GraphQLSchema({
    query: new GraphQLObjectType({
      name: &quot;Query&quot;,
      fields: {
        query1,
        query2,
        query3
      }
    })
  });
  
  const permissions = shield(
    {
      Query: {
        query1: user,
        query2: user,
        query3: admin
      }
    }
  )
  </code></pre>
  <p>(much longer in the reality)</p>
  <p>And I'm looking for a way to make it clearer, like:</p>
  <pre class="lang-js prettyprint-override"><code>const { query1 } = require('query1')
  const { query2 } = require('query2')
  const { query3 } = require('query3')
  
  const declaration = {
       query1: user,
       query2: user,
       query3: admin
  }
  
  const schema = new GraphQLSchema({
   query: new GraphQLObjectType({
     name: &quot;Query&quot;,
     fields: someMagic(declaration)
   })
  });
  
  const permissions = shield(
   {
     Query: declaration
   }
  )
  </code></pre>
  <p>But here <code>declaration</code> keys are the strings &quot;query1&quot;, &quot;query2&quot; and &quot;query3&quot;. Not the objects.</p>
  <p>With a <code>WeakMap</code> we could have something like:</p>
  <pre class="lang-js prettyprint-override"><code>const declaration = new WeakMap();
  
  declaration.set(query1, user);
  declaration.set(query2, user);
  declaration.set(query3, admin);
  </code></pre>
  <p>But I find it much less elegant. Is there another way ?</p>