How to use the graphback.CRUDService function in graphback

To help you get started, we’ve selected a few graphback examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aerogear / graphql-testx / src / GraphbackServer.ts View on Github external
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 });