Last active
March 26, 2019 10:35
-
-
Save szaza/2966f8c22b2205330e9b9d3d0835a541 to your computer and use it in GitHub Desktop.
Workaround for GraphQL schema stitching error swallowing problem.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "reflect-metadata"; | |
import * as dotenv from "dotenv"; | |
import * as hapi from "hapi"; | |
import { TYPES } from "./common/types"; | |
import { ApolloServer } from "apollo-server-hapi"; | |
import { connectToDB } from "./persistence/persistence-context"; | |
import { RootApi } from "./api/root-api"; | |
import { Logger } from "winston"; | |
import diContainer from "./common/di-container"; | |
import console = require("console"); | |
const rootApi: RootApi = diContainer.get<RootApi>(TYPES.ROOT_API); | |
dotenv.config(); | |
const PORT = 8081; | |
const startServer = async () => { | |
const server = new ApolloServer({ | |
schema: rootApi.getRootSchema(), | |
introspection: true, | |
playground: true, | |
formatError: error => { | |
console.log(error.message); | |
return { message: error.message }; | |
} | |
}); | |
const app = new hapi.Server({ port: PORT }); | |
await server.applyMiddleware({ app }); | |
await server.installSubscriptionHandlers(app.listener); | |
await app.start(); | |
}; | |
startServer() | |
.then(() => { | |
console.log(`Server started on port: ${PORT}`); | |
}) | |
.catch(error => console.log(error.message)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment