GraphQL server.

The GraphQL server per se is a simple express application:

importexpressfrom'express';importgraphqlHTTPfrom'express-graphql';varpath=require('path');exportdefaultfunction(schema,port){varapp=express();app.use(express.static(path.join(__dirname,'static')));app.use('/graphql',graphqlHTTP(function(){return{schema:schema};}));app.use('/schema',function(req,res,_next){varprintSchema=require('graphql/utilities/schemaPrinter').printSchema;res.set('Content-Type','text/plain');res.send(printSchema(schema));});app.listen(port);console.log(`Started on http://localhost:${port}/`);}

A few things to highlight :

we will serve the static files from the static directory - in particular index.html.

the actual GraphQL API is served from the /graphql path. If you want to change that path, you will have to also update the index.html file accordingly

the /schema is a utility path so that you can display the actual schema in the browser.