Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async init() {
this.backendCreator = new GraphQLBackendCreator(this.model, this.config);
this.backend = await this.backendCreator.createBackend("sqlite3");
}
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;
}
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();
}
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();
}
private async generateDatabase(): Promise {
const manager = new DatabaseSchemaManager("sqlite3", {
filename: ":memory:"
});
this.backendCreator.registerDataResourcesManager(manager);
await this.backendCreator.createDatabase();
return manager.getConnection();
}
}
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 });
constructor(knex: Knex) {
this.knex = knex;
this.provider = new KnexDBDataProvider(knex);
}
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);
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();
constructor(options: TestxServerOptions) {
this.options = options;
this.context = graphQLInputContext.createModelContext(
options.schema,
DEFAULT_CONFIG
);
}