Skip to content

Instantly share code, notes, and snippets.

@szaza
Last active March 26, 2019 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szaza/2966f8c22b2205330e9b9d3d0835a541 to your computer and use it in GitHub Desktop.
Save szaza/2966f8c22b2205330e9b9d3d0835a541 to your computer and use it in GitHub Desktop.
Workaround for GraphQL schema stitching error swallowing problem.
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