title: NodeJS: Get File, not Buffer
body: <p>I have set up a mutation on my <code>apollo</code> GraphQL server with <code>graphql-upload</code> <em>(or <code>apollo-upload-server</code>)</em> to receive a file from the client, and now I'm trying to write a test for this mutation but I'm not sure how to attach the actual file to my mock request.</p>
  
  <p>On my client I have an <code>input type="file"</code> and on upload event I extract the file </p>
  
  <pre><code>async upload(event) {
    const files = event.target.files || event.dataTransfer.files;
    const file = files[0]; // type of file is File
    await apollo.mutate({
      mutation: gql`
        mutation UploadFile($file: Upload) {
          uploadFile(file: $file)
        }
      `,
      variables: { file },
    })
  }
  </code></pre>
  
  <p>So far all is good. But I would like to write a test case on my server as well.</p>
  
  <p><strong>This is my problem</strong></p>
  
  <p>On my server, I would like to mimic the client uploading the file. But I can't find how I'd access the actual file from within NodeJS.</p>
  
  <p>I've tried:</p>
  
  <pre><code>const file = fs.readFileSync('path/to/test-file.csv');
  </code></pre>
  
  <p>But <code>fs</code> returns a <code>Buffer</code>, not of type <code>File</code> which also contains meta-data, such as <code>mimetype</code>, <code>name</code>, <code>lastModified</code> properties for instance.</p>
  
  <p>How do I get the actual <code>File</code> <strong>object</strong> and not the <code>Buffer</code>?</p>
  
  <p>Thanks!</p>