Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
config = await getConfig({
datamodelPath: schemaPath,
})
const datasource = config.datasources[0]
if (!datasource) {
throw new Error(
`Either provide ${chalk.greenBright('--url')} or add a ${chalk.greenBright.bold(
'datasource',
)} in the ${chalk.greenBright(path.relative(process.cwd(), schemaPath))} file.`,
)
}
url = datasource.url.value
}
const engine = new IntrospectionEngine({
cwd: schemaPath ? path.dirname(schemaPath) : undefined,
})
const basedOn =
!args['--url'] && schemaPath
? ` based on datasource defined in ${chalk.underline(path.relative(process.cwd(), schemaPath))}`
: ''
log(`Introspecting${basedOn} …`)
const before = Date.now()
let introspectionSchema = await engine.introspect(url)
engine.stop()
if (introspectionSchema.trim() === '') {
throw new Error(`Empty introspection result for ${chalk.underline(url)}`)
}