Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function initGraphbackServer(
context: InputModelTypeContext[],
data: GraphbackDataProvider,
serviceBuilder?: ServiceBuilder
): Promise {
const schemaGenerator = new SchemaGenerator(context);
const schema = schemaGenerator.generate();
const sub = new PubSub();
const service: GraphbackCRUDService = serviceBuilder
? await serviceBuilder(data, sub)
: new CRUDService(data, sub);
const resolverGenerator = new LayeredRuntimeResolverGenerator(
context,
service
);
const resolvers = resolverGenerator.generate();
const express = newExpress();
const apollo = new ApolloServer({
typeDefs: schema,
resolvers: resolvers
});
apollo.applyMiddleware({ app: express, path: ENDPOINT });
const httpServer = createServer(express);
apollo.installSubscriptionHandlers(httpServer);