Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function start() {
const app = express();
app.use(cors());
app.get('/health', (req, res) => res.sendStatus(200));
const config = await loadConfig({
extensions: [() => ({ name: 'generate' })]
});
const generateConfig = await config!.getDefault().extension('generate');
// connect to db
const db = await connect(generateConfig.db.dbConfig);
const schema = makeExecutableSchema({
typeDefs,
resolvers,
resolverValidationOptions: {
requireResolversForResolveType: false
}
});
export async function findAndLoadGraphQLConfig(filepath?: string): Promise {
const config = await loadConfig({
filepath,
rootDir: process.cwd(),
extensions: [CodegenExtension],
throwOnEmpty: false,
throwOnMissing: false,
});
if (isGraphQLConfig(config)) {
return config;
}
}
export async function connect(options: knex.MySqlConnectionConfig) {
const config = await loadConfig({
extensions: [() => ({ name: 'generate'})]
});
const { db } = await config!.getDefault().extension('generate');
return knex({
client: db.database,
connection: options
})
}