This is the GraphQL backend for the Skole app.
Also check out the README from skole
repo.
See detailed description for all top-level dependencies in dependencies.md
file.
A quick look at the top-level files and directories excluding Git ignored locations.
.github/
: Configuration for Github Actions..idea/
: Jetbrains editor configuration.config/
: Configuration for Django project.media/
: Few media files for testing.skole/
: Source code..dockerignore
: List of files not sent to Docker build context..flake8
: Configuration for Flake8..gitattributes
: Additional Git repo metadata..gitignore
: List of files ignored by Git..graphqlconfig
: GraphQL configuration file, used by JS GraphQL JetBrains IDE plugin.Dockerfile
: Formal instructions for Docker how to build the image for the app.README.md
: The file you're reading.dependencies.md
: Documentation about the project's top-level dependencies.manage.py
: Auto-generated for a Django project, see docs.mypy.ini
: Configuration for Mypy.pyproject.toml
: Lists project's PyPI dependencies and contains configuration for various Python tools.schema.graphql
: GraphQL schema for noticing schema changes quickly from PRs.
-
No pull requests can be merged without CI pipeline first building and running
Dockerfile
against it. See theCMD
of theci
stage for the full list of stuff it runs and validates. The CI pipeline also verifies the code style, so there is no need to argue about formatting. -
Use Google style docstrings.
-
All
assert
statements are just for type checking or for generally helping the developer. They should not be used for actual program logic since they are stripped away in production with the use of thePYTHONOPTIMIZE=1
env variable.
- Inherit all models from
SkoleModel
orTranslatableSkoleModel
. - Inherit all managers from
SkoleManager
orTranslatableSkoleManager
. - Inherit all forms from
SkoleForm
,SkoleModelForm
, orSkoleUpdateModelForm
. - Inherit all mutations from
SkoleCreateUpdateMutationMixin
orSkoleDeleteMutationMixin
. - Inherit all GraphQL object types from
SkoleObjectType
. - Inherit all graphene-django object types from
SkoleDjangoObjectType
.
-
Do not access any "private" names starting with an underscore
_
outside the class or module where it's defined, without a very good reason. -
Do not manually call
Model.save()
outside of model files. It's fine to callsave()
on aModelForm
to save the instance though. -
Sometimes Mypy doesn't understand a type, and that's completely fine. In these cases ignore only the specific error with
# type: ignore[err-name]
AND write a comment starting with# Ignore:
on top of it, which explains why the ignore was needed. -
All monkey patched code affecting 3rd party modules should go into
patched.py
. The compatibility of the patched code should also be verified with a test intest_patched.py
. -
Since
_
is reserved as an alias for Django's translation functions, use a double underscore__
for ignored values, e.g.foo, __ = Foo.objects.get_or_create(...)
or[bar() for __ in range(n)]
. -
All GraphQL queries should be documented in their resolver docstring. All mutations should be documented in their class docstring. This info is shown in GraphiQL docs, together with information automatically taken from the actual code (see
SkoleObjectTypeMeta
for details). -
Use the
@login_required
decorator defined inskole.overridden
instead of the one ingraphql_jwt.decorators
. The former automatically adds authorization required information to the API docs. -
Whenever you add fields to
User
model, or relations tosettings.AUTH_USER_MODEL
, make sure to add those toMyDataMutation
inskole.schemas.gdpr
. -
It's fine to use PostgreSQL specific Django utilities, such as
ArrayAgg
. They can make life a lot easier, and we can assume that the application is always run on Postgres. -
Don't use relative imports (
from .foo import bar
) outside of__init__.py
files. -
Use
@test.test
for all email addresses when testing/developing. This makes their intent very clear since.test
is not a valid TLD. Also,test.test
has been whitelisted insettings.ALLOWED_EMAIL_DOMAINS
. -
Use
from __future__ import annotations
in all non-empty source files to guarantee forwards compatibility with PEP-563.