Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move seeding outside of /api/graphql #101

Open
eric-burel opened this issue Apr 19, 2021 · 1 comment
Open

Move seeding outside of /api/graphql #101

eric-burel opened this issue Apr 19, 2021 · 1 comment

Comments

@eric-burel
Copy link
Collaborator

eric-burel commented Apr 19, 2021

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:

  1. move seed code outside of "/api/graphql", into it's own independent script, in a "scripts" folder
  2. setup an environment that stills allows to use TS in this script (eg running the script with node-ts or whatever)
  3. run this script on "predev" in package.json (and maybe "prestart" for prod? we don't seed yet in production)
@eric-burel eric-burel added bug Something isn't working easy / good first issue Good for newcomers mongo node labels Apr 19, 2021
@eric-burel
Copy link
Collaborator Author

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.

@eric-burel eric-burel self-assigned this Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant