title: File uploads with graphql-upload, apollo-server-fastify, and the NestJS code first approach
body: <p>What is the correct implementation for receiving file uploads from a client on a server utilizing the following combination of packages/techniques (and their corresponding dependencies not listed): </p>
  
  <ul>
  <li><code>graphql-upload</code></li>
  <li><code>apollo-server-fastify</code></li>
  <li><code>@nestjs/platform-fastify</code> (code first approach)</li>
  </ul>
  
  <p>Ideally, we are trying to implement the following (from <a href="https://www.apollographql.com/docs/apollo-server/data/file-uploads/" rel="noreferrer">apollo server file uploads</a>) using the NestJS GraphQL Code First technique (except for multiple files instead of just one)</p>
  
  <pre><code>const { ApolloServer, gql } = require('apollo-server');
  
  const typeDefs = gql`
    type File {
      filename: String!
      mimetype: String!
      encoding: String!
    }
  
    type Query {
      uploads: [File]
    }
  
    type Mutation {
      singleUpload(file: Upload!): File!
    }
  `;
  
  const resolvers = {
    Query: {
      uploads: (parent, args) =&gt; {},
    },
    Mutation: {
      singleUpload: (parent, args) =&gt; {
        return args.file.then(file =&gt; {
          //Contents of Upload scalar: https://github.com/jaydenseric/graphql-upload#class-graphqlupload
          //file.stream is a node stream that contains the contents of the uploaded file
          //node stream api: https://nodejs.org/api/stream.html
          return file;
        });
      },
    },
  };
  
  const server = new ApolloServer({
    typeDefs,
    resolvers,
  });
  
  server.listen().then(({ url }) =&gt; {
    console.log(` Server ready at ${url}`);
  });
  </code></pre>
  
  <p>Right now, my frontend is correctly sending the files to my server using this mutation:</p>
  
  <pre><code>gql`
    mutation uploadObjects($files: [Upload!]!) {
      uploadObjects(files: $files) {
        bucketKey
      }
    }
  `;
  
  </code></pre>
  
  <p>Here are links to images of the request being sent with the file binaries as expected:</p>
  
  <ul>
  <li><a href="https://cdn.discordapp.com/attachments/601536926268260392/641305325718208522/unknown.png" rel="noreferrer">link1</a></li>
  <li><a href="https://cdn.discordapp.com/attachments/601536926268260392/641305350267469834/unknown.png" rel="noreferrer">link2</a></li>
  </ul>