How to use graphback - 10 common examples

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 / BackendBuilder.ts View on Github external
private async init() {
    this.backendCreator = new GraphQLBackendCreator(this.model, this.config);
    this.backend = await this.backendCreator.createBackend("sqlite3");
  }
github aerogear / graphql-testx / src / graphback-core / index.ts View on Github external
export async function generateTypeDefs(
  model: string,
  config: { [id: string]: any },
) {
  const creator = new GraphQLBackendCreator(model, config);
  const backend = await creator.createBackend("sqlite3");

  const { typeDefs } = sourceModule(transpile(backend.schema));
  return typeDefs;
}
github aerogear / graphql-testx / src / graphback-core / index.ts View on Github external
export async function generateDatabase(
  model: string,
  config: { [id: string]: any },
) {
  const backend: GraphQLBackendCreator = new GraphQLBackendCreator(
    model,
    config,
  );

  const connectionConfig = {
    filename: `${folders.database}/db.sqlite`,
  };

  const manager = new DatabaseSchemaManager("sqlite3", connectionConfig);
  backend.registerDataResourcesManager(manager);

  await backend.createDatabase();
}
github aerogear / graphql-testx / src / graphback-core / index.ts View on Github external
export async function generateDatabase(
  model: string,
  config: { [id: string]: any },
) {
  const backend: GraphQLBackendCreator = new GraphQLBackendCreator(
    model,
    config,
  );

  const connectionConfig = {
    filename: `${folders.database}/db.sqlite`,
  };

  const manager = new DatabaseSchemaManager("sqlite3", connectionConfig);
  backend.registerDataResourcesManager(manager);

  await backend.createDatabase();
}
github aerogear / graphql-testx / src / BackendBuilder.ts View on Github external
private async generateDatabase(): Promise {
    const manager = new DatabaseSchemaManager("sqlite3", {
      filename: ":memory:"
    });
    this.backendCreator.registerDataResourcesManager(manager);
    await this.backendCreator.createDatabase();
    return manager.getConnection();
  }
}
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 });
github aerogear / graphql-testx / src / InMemoryDatabase.ts View on Github external
constructor(knex: Knex) {
    this.knex = knex;
    this.provider = new KnexDBDataProvider(knex);
  }
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 });

  const httpServer = createServer(express);
  apollo.installSubscriptionHandlers(httpServer);
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();
github aerogear / graphql-testx / src / TestxServer.ts View on Github external
constructor(options: TestxServerOptions) {
    this.options = options;

    this.context = graphQLInputContext.createModelContext(
      options.schema,
      DEFAULT_CONFIG
    );
  }