title: Access JSON chunk exported from Gatsby Static Query
body: <p>I have a React Component in a Gatsby app that is using the <a href="https://www.gatsbyjs.org/docs/use-static-query/" rel="nofollow noreferrer"><code>useStaticQuery</code></a> hook to pull in data from the GraphQL layer. This component gets used in my application, but it also gets used as part of a JavaScript embed/widget that is created in a separate Webpack configuration. </p>
  
  <p>I don't want the widget to depend on Gatsby, so I've shimmed the relevant bits of Gatsby, but I still need to pass in data to the shim I've created for <code>useStaticQuery</code>. I found that my Gatsby app is generating a file at <code>public/static/d/2250905522.json</code> that contains a perfect representation of the query data, and I'd like to use it like so:</p>
  
  <pre><code>// This file gets substituted when importing from `gatsby`
  
  import queryResult from "../public/static/d/2250905522.json"
  
  export const useStaticQuery = () =&gt; queryResult.data
  
  export const graphql = () =&gt; {}
  </code></pre>
  
  <p>This works, but I haven't figured out where this is coming from or how to determine the file name in a way that is deterministic/stable. How is Gatsby determining this file name, and what internals might I use to do the same?</p>
  
  <p>Edit: I found <a href="https://github.com/gatsbyjs/gatsby/blob/610b5812a815f9ecff422e9087c851cd103c8e7e/packages/gatsby/src/utils/websocket-manager.js#L89-L95" rel="nofollow noreferrer">this routine</a> in the Gatsby codebase that appears to be using <code>staticQueryComponent.hash</code> to determine the number. <code>staticQueryComponent</code> is being destructured from <code>store.getState()</code> where <code>store</code> is associated with Redux, but I'm still not sure where the hash is being determined yet.</p>
  
  <p>Edit 2: Found <a href="https://github.com/gatsbyjs/gatsby/blob/20afc1b7fbd0e7d722f93f7d345531ce48bb5de7/docs/docs/static-vs-normal-queries.md#replacing-queries-with-json-imports" rel="nofollow noreferrer">another mention of this in the documentation here</a>. It sounds like <code>hash</code> is a hash of the query itself, so this will change over time if the query changes (which is likely), so I'm still looking for the routine used to compute the hash.</p>