const { graphqlHTTP } = require('express-graphql'); const { buildSchema } = require('graphql'); const { createServer } = require('./api/servers'); const { GraphQLUpload, graphqlUploadExpress } = require('graphql-upload'); const schema = buildSchema(` scalar Upload type Server { id: ID!, // stuff... } input ServerInput { bannerFile: Upload, name: String!, address: String!, description: String! } type Mutation { createServer(input: ServerInput!): Server } `); // The root provides a resolver function for each API endpoint const root = { createServer, Upload: GraphQLUpload }; module.exports = function(app) { app.use('/api', graphqlUploadExpress({ maxFileSize: 1000000, maxFiles: 1 }), graphqlHTTP({ schema: schema, rootValue: root, graphiql: true, customFormatErrorFn: err => ({ message: err.message }) })); };