This commit is contained in:
parent
62c8d51c5d
commit
993f064633
8
CHANGELOG.txt
Normal file
8
CHANGELOG.txt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[0.0.2]
|
||||||
|
- dx: migrated to strawberry
|
||||||
|
- dx: added sentry integration
|
||||||
|
- dx: added mypy plugins
|
||||||
|
- dx: pyright settings
|
||||||
|
|
||||||
|
[0.0.1]
|
||||||
|
- dummy ariadne version
|
|
@ -22,7 +22,7 @@
|
||||||
Затем
|
Затем
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
poetry install
|
|
||||||
poetry env use 3.12
|
poetry env use 3.12
|
||||||
poetry run python server.py
|
poetry install
|
||||||
|
poetry run strawberry server main
|
||||||
```
|
```
|
||||||
|
|
13
main.py
13
main.py
|
@ -2,6 +2,7 @@ import os
|
||||||
import asyncio
|
import asyncio
|
||||||
from os.path import exists
|
from os.path import exists
|
||||||
|
|
||||||
|
from sentry_sdk.integrations.strawberry import StrawberryIntegration
|
||||||
from strawberry.asgi import GraphQL
|
from strawberry.asgi import GraphQL
|
||||||
from starlette.applications import Starlette
|
from starlette.applications import Starlette
|
||||||
|
|
||||||
|
@ -27,7 +28,17 @@ async def start_up():
|
||||||
try:
|
try:
|
||||||
import sentry_sdk
|
import sentry_sdk
|
||||||
|
|
||||||
sentry_sdk.init(SENTRY_DSN)
|
sentry_sdk.init(
|
||||||
|
SENTRY_DSN,
|
||||||
|
enable_tracing=True,
|
||||||
|
integrations=[
|
||||||
|
StrawberryIntegration(
|
||||||
|
# Set async_execution to True if you have
|
||||||
|
# at least one async resolver
|
||||||
|
async_execution=True
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("[sentry] init error")
|
print("[sentry] init error")
|
||||||
print(e)
|
print(e)
|
||||||
|
|
|
@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "discoursio-notifier"
|
name = "discoursio-notifier"
|
||||||
version = "0.0.1"
|
version = "0.0.2"
|
||||||
description = "notifier server for discours.io"
|
description = "notifier server for discours.io"
|
||||||
authors = ["discours.io devteam"]
|
authors = ["discours.io devteam"]
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ httpx = "^0.25.0"
|
||||||
psycopg2-binary = "^2.9.9"
|
psycopg2-binary = "^2.9.9"
|
||||||
redis = {extras = ["hiredis"], version = "^5.0.1"}
|
redis = {extras = ["hiredis"], version = "^5.0.1"}
|
||||||
uvicorn = "^0.24.0.post1"
|
uvicorn = "^0.24.0.post1"
|
||||||
strawberry-graphql = { extras = ["asgi"], version = "^0.215.1" }
|
strawberry = {package = "strawberry-graphql", extras = ["asgi", "debug-server"], version = "^0.215.1" }
|
||||||
sentry-sdk = "^1.37.1"
|
sentry-sdk = "^1.37.1"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
|
@ -69,4 +69,4 @@ executionEnvironments = []
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
python_version = "3.12"
|
python_version = "3.12"
|
||||||
warn_unused_configs = true
|
warn_unused_configs = true
|
||||||
plugins = ["mypy_sqlalchemy.plugin"]
|
plugins = ["mypy_sqlalchemy.plugin", "strawberry.ext.mypy_plugin"]
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from typing import List
|
||||||
|
|
||||||
import strawberry
|
import strawberry
|
||||||
from sqlalchemy import and_
|
from sqlalchemy import and_
|
||||||
from orm.author import Author
|
from orm.author import Author
|
||||||
|
@ -45,10 +47,10 @@ def notification_seen_by_viewer(viewer_id, notification_id, session):
|
||||||
|
|
||||||
@strawberry.type
|
@strawberry.type
|
||||||
class Query:
|
class Query:
|
||||||
@login_required
|
|
||||||
@strawberry.field
|
@strawberry.field
|
||||||
async def load_notifications(self, info, limit: int = 50, offset: int = 0) -> dict:
|
@login_required
|
||||||
"""непрочитанные уведомления"""
|
async def load_notifications(self, info, limit: int = 50, offset: int = 0) -> dict[str, List[Notification] | int]:
|
||||||
|
"""загружаем уведомления"""
|
||||||
user_id = info.context["user_id"]
|
user_id = info.context["user_id"]
|
||||||
|
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user