mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-09 20:53:10 +00:00
feature(jobs): websocket connection
This commit is contained in:
parent
9bfffcd820
commit
63d2e48a98
|
@ -3,6 +3,7 @@
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from strawberry.fastapi import GraphQLRouter
|
from strawberry.fastapi import GraphQLRouter
|
||||||
|
from strawberry.subscriptions import GRAPHQL_TRANSPORT_WS_PROTOCOL, GRAPHQL_WS_PROTOCOL
|
||||||
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
|
|
||||||
|
@ -13,8 +14,12 @@ from selfprivacy_api.migrations import run_migrations
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
graphql_app = GraphQLRouter(
|
graphql_app: GraphQLRouter = GraphQLRouter(
|
||||||
schema,
|
schema,
|
||||||
|
subscription_protocols=[
|
||||||
|
GRAPHQL_TRANSPORT_WS_PROTOCOL,
|
||||||
|
GRAPHQL_WS_PROTOCOL,
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
|
|
6
tests/test_graphql/test_websocket.py
Normal file
6
tests/test_graphql/test_websocket.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
def test_websocket_connection_bare(authorized_client):
|
||||||
|
client =authorized_client
|
||||||
|
with client.websocket_connect('/graphql', subprotocols=[ "graphql-transport-ws","graphql-ws"] ) as websocket:
|
||||||
|
assert websocket is not None
|
||||||
|
assert websocket.scope is not None
|
Loading…
Reference in a new issue