import * as express from "express"; import * as graphqlHTTP from "express-graphql"; import {buildSchema} from "graphql"; import { GameServer } from "./GameServer"; import { createSampleMaps } from "./SampleMaps"; const port = 8080; const apiRoot = "/graphql"; const app = express(); const schema = buildSchema(` """ Representing a tile with it's possible pathways. """ type MazeTile { id: String! paths: [Int!]! } type Query { currentPostition(userID: String!): MazeTile "Lists currently available maps." listMaps: [String!]! } `); const games = new GameServer(); const maps = createSampleMaps(); maps.forEach(m => games.addMap(m)); const root = { currentPostition: ({userID}) => games.currentPosition(userID), listMaps: () => games.listMaps(), }; app.use(apiRoot, graphqlHTTP({ graphiql: true, rootValue: root, schema, })); app.listen(port, () => console.log(`App listening on port ${port}...`));