Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const createRuntime = async (client: Knex) => {
const schemaText = loadSchema(jsonConfig.folders.model);
const backend = new GraphQLBackendCreator(schemaText, jsonConfig.graphqlCRUD);
const dbClientProvider = new PgKnexDBDataProvider(client);
const dbConfig = {
client: jsonConfig.db.database,
connection: jsonConfig.db.dbConfig
};
migrateDB(dbConfig, schemaText).then((ops) => {
console.log(ops);
});
const pubSub = new PubSub();
const runtime = await backend.createRuntime(dbClientProvider, pubSub);
const generatedSchema = runtime.schema;
const executableSchema = makeExecutableSchema({
typeDefs: gql`${generatedSchema}`,
resolvers: runtime.resolvers,
resolverValidationOptions: {
requireResolversForResolveType: false
}
});
return executableSchema;
}
logError(`No graphql file found inside ${process.cwd()}/model folder.`)
process.exit(0)
}
if (database === 'sqlite3') {
await execa('touch', ['db.sqlite'])
}
const dbConfig = {
client: config.db.database,
connection: config.db.dbConfig
}
const schemaText = loadSchema(folders.model);
databaseOperations = await migrateDB(dbConfig, schemaText);
} catch (err) {
handleError(err)
}
return databaseOperations;
}