django + graphql实现前后端分离。支持jwt登录效验,以及resolver权限绑定。
pip install -r requirements.txt
打开core/setting.py,找到databases选项并修改
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'jouryu_django',
'USER': 'root',
'PASSWORD': '!',
'HOST': '127.0.0.1',
'OPTIONS': {
'init_command': 'SET default_storage_engine=INNODB;'
}
}
}
例:CREATE DATABASE jouryu_django DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
无需效验登录:http://127.0.0.1:8000/unauthorized_graphiql 需要效验登录:http://127.0.0.1:8000/graphiql