-
Notifications
You must be signed in to change notification settings - Fork 5
Frequently Asked Questions
This document is intended to serve as a reference for common workflows and answer frequently asked questions during development. It is not intended to replace the documentation for the tools used in the project. The vast majority of the tools used in this project are very well documented, and actively using the documentation for these tools is an excellent way of understanding and resolving issues. The documentation for the most important tools can be found here:
While reading documentation may seem daunting and boring at first, I promise that it is an extremely effective tool and an important skill, so it is worthwhile to learn it.
- Django: https://docs.djangoproject.com/en/3.2/
- React: https://react.dev
- Next.js: https://nextjs.org/docs
- Material UI: https://mui.com/material-ui/getting-started/overview/
- Apollo Client: https://www.apollographql.com/docs/react/
Instead of maintaining our own guide for Git, it is highly recommended that you read GitHub flow. Getting comfortable with the Git flow makes it a lot easier to work on the project. Don't worry, you cannot break anything in production without merging a broken pull request to main
(but please don't 😇). 🔨
-
Starting docker compose
- All services:
$ docker compose up
- Specific service:
where
$ docker compose up <service-name>
<service-name>
is eitherbackend
,frontend
, orpostgres
- All services:
-
Executing commands in a running container
$ docker compose exec <service-name> <command>
where
<service-name>
is eitherbackend
,frontend
, orpostgres
and<command>
is the command you want to execute in the container.
After running python manage.py loaddata initial_data
, you can log in to the application using the following users:
Username | Password | Permissions |
---|---|---|
eva_student | 098asd | indok |
asbjorn_elevg | 098asd | non-indok |
admin | admin123 | super |
If you're running the server using Docker Compose, remember to prefix the commands with docker compose exec backend
.
If you have made changes to the database models, i.e. changed fields in one of the classes in apps/**/models.py
, you need to create a migration file. This is done by running the following commands in the terminal:
$ python manage.py makemigrations
Afterwards, to apply the migration:
$ python manage.py migrate
To activate the virtual environment created during the project setup, run
$ source .venv/bin/activate
It is also possible to set up an alias for this command in your shell configuration file (e.g. .bashrc
or .zshrc
). For instance:
$ echo > alias activate="source .venv/bin/activate" >> ~/.zshrc
Then you can run activate
to activate the virtual environment.
If you've made changes to the GraphQL schema, or you've updated a query in the frontend, you need to generate the typescript types for the queries. This is done automatically if you run yarn dev
or yarn build
, but you can also run it manually:
# in frontend/
$ yarn generate
Often due to outdated or missing dependencies, run
# in frontend/
$ yarn
to install and update dependencies, then run
# in frontend/
$ yarn dev
again.
In increasing order of nuking power:
Stopping the containers and clearing the volumes
$ docker compose down -v
Nuking absolutely every image, volume, and container on your system
$ docker system prune --volumes -a
-
Create and apply a migration, see Database Migration
-
In
backend/apps/<your-app>/types.py
, add the field to thefields
list in the meta class. For instance:class MyType(DjangoObjectType): class Meta: fields = [ ..., my_new_field ]
-
Update the GraphQL schema by running
$ python manage.py graphql_schema
-
In
frontend/
, update the query where you want to include the field. For instance, infrontend/src/graphql/my-app/queries.graphql
:query myQuery { myQuery { id ...myNewField } }
-
Generate Typescript types based on the GraphQL schema, see Generate Typescript Types for GraphQL Queries.
-
You can now access the newly added field with the correct types wherever you're calling the query.
The vast majority of the time, it's because something in the code is wrong. Click on the status check, find the error, and try to interpret why it is occuring, then fix the issue.