0.4.11-b
All checks were successful
Deploy on push / deploy (push) Successful in 56s

This commit is contained in:
Untone 2025-02-12 22:34:57 +03:00
parent 1de3d163c1
commit 5263d1657e
2 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,6 @@
#### [0.4.11] - 2025-02-12
- `create_draft` resolver requires draft_id fixed
- `create_draft` resolver defaults body field to empty string
#### [0.4.9] - 2025-02-09

View File

@ -68,7 +68,7 @@ async def create_draft(_, info, draft_input):
info: GraphQL context
draft_input (dict): Draft data including optional fields:
- title (str)
- body (str)
- body (str, required) - текст черновика
- slug (str)
- etc.
@ -93,12 +93,19 @@ async def create_draft(_, info, draft_input):
if not user_id or not author_id:
return {"error": "Author ID is required"}
# Проверяем обязательные поля
if "body" not in draft_input or not draft_input["body"]:
draft_input["body"] = "" # Пустая строка вместо NULL
try:
with local_session() as session:
# Remove id from input if present since it's auto-generated
if "id" in draft_input:
del draft_input["id"]
# Добавляем текущее время создания
draft_input["created_at"] = int(time.time())
draft = Draft(created_by=author_id, **draft_input)
session.add(draft)
session.commit()