title: How do I add variables to a GraphQL File query
body: <p>I'm using the <code>gatsby-image</code> plugin to display images on my Gatsby site. In my GraphQL query, I want to be able to pass in a variable to the <code>relativePath</code> argument as this query is being run (in the parent component) for a number of components that require images. I cannot seem to figure out how to do this though.</p>
  
  <p>This is what my query looks like: </p>
  
  <pre><code>...
  
  const imgData = useStaticQuery(graphql`
          query{
              file(relativePath: {eq: "talent.png"}) {
                  childImageSharp {
                      fixed (width: 289, height: 589) {
                          ...GatsbyImageSharpFixed
                      }
                  }
              }
          }
      `)
  </code></pre>
  
  <p>I want to replace that "talent.png" with a variable so I can use this query across components. This is my desired query:</p>
  
  <pre><code>const imgData = useStaticQuery(graphql`
          query($pageImg: String!){
              file(relativePath: {eq: $pageImg}) {
                  childImageSharp {
                      fixed (width: 289, height: 589) {
                          ...GatsbyImageSharpFixed
                      }
                  }
              }
          }
      `)
  </code></pre>
  
  <p>I have tried adding a context to the page using <code>onCreatePage</code> in <code>gatsby-node.js</code>. This would work for a page query but the file node obviously does not recognise page context. So I tried adding a context to the file node:</p>
  
  <pre><code>module.exports.onCreateNode = ({ node, actions }) =&gt; {
      const { createNodeField } = actions
  
      if(node.internal.type === 'File'){
          createNodeField({
              node,
              name: 'context',
              value: {
                  pageImg: node.relativePath
              }
          })
      }
  }
  </code></pre>
  
  <p>But still I get this error:
  <code>Variable "$pageImg" of required type "String!" was not provided.</code></p>
  
  <p>Any help in understanding how to solve this issue will be greatly appreciated.</p>