Scala-graphql-bootstrap setup the groundwork for a scala/reactjs project using graphql.
It brings an akka server, structure for graphql class, setup link to mysql, handle migration using slick and a frontend client using reactjs/apollo. All in a mono-repo and launched with docker-compose.
The only dependency you need is docker. If you decide to not use docker you will have to install each project independently.
A simple make first will build the containers, install dependency for scala & react, and run the db migrations.
After that, you will be able to run the project with make run.
Once everything is installed and the server is running you can go on localhost:8080 to play with it.
- NAME="yourproject"; find . -type f -not -path "./.git/*" -exec sed -i 's/bootstrap/'"$NAME"'/g' {} ;
- NAME="yourproject"; mv ./backend/app/src/main/scala/com/bootstrap ./backend/app/src/main/scala/com/$NAME
- Update
backend/app.jsonfile with your application description. - Update initial migration
- Run
make first - git remote rm origin
- git remote add origin $your_project_repository
A migration for User & Token already exists. These 2 tables are used for the authentification in graphql. If you decide to modify them, you will have to modify the AuthMiddleware.scala file.
You can find the migration here: backend/migrations/src_migrations/main/scala/1.scala
If you modify this class after running the test project, run make clean_local_db clean_generated_code migrate to reset your local db & update your generated code.
For new migration run make new_migration, update the newly created file and add any new table to backend/migrations/src/main/scala/Codegen.scala. Then run make migrate.
The akka server, the migration script, generated class. Anything needed to run a grapqhl server
backend/app: The actual application. Where you will spend most of your timebackend/generated_code: data classes generated by scala-forklift when running the migrationbackend/migration_manager&backend/migrations: reserved for scala-forklift.
A create-react-app application with apollo
- Scala
- Akka server
- Slick
- Graphql & Sangria
- ReactJs
- Graphql & Apollo
This project uses slick the data mapping between class and MySQL (http://slick.lightbend.com/).
The data classes are automatically generated using scala-forklift (https://github.com/lastland/scala-forklift).
Check how to add new migration here: https://github.com/lastland/scala-forklift/tree/develop/example