vulcan-next
vulcan-next copied to clipboard
Move seeding outside of /api/graphql
Describe the bug Seed logic doesn't belong to any endpoint. In a serverless approach, seeding should hapeen in a "predev" or "prestart" script that is run globally at application startup .
To Reproduce
On a fresh, empty database, try running /api/login
before /api/graphql => admin user won't be seeded. This is because the seed happens only in /api/graphql
.
Expected behavior Seeding should happen before "yarn dev", not inside API routes.
To fix:
- move seed code outside of "/api/graphql", into it's own independent script, in a "scripts" folder
- setup an environment that stills allows to use TS in this script (eg running the script with node-ts or whatever)
- run this script on "predev" in package.json (and maybe "prestart" for prod? we don't seed yet in production)
In progress, thanks to the new ability to build TypeScript files as independant scripts. We already have introduced db:seed
and db:reset
. We could document them as scripts to run after app creation.