feature(jobs): websocket connection

This commit is contained in:
Houkime 2024-05-15 11:29:20 +00:00 committed by Inex Code
parent 9bfffcd820
commit 63d2e48a98
2 changed files with 12 additions and 1 deletions

View file

@ -3,6 +3,7 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from strawberry.fastapi import GraphQLRouter
from strawberry.subscriptions import GRAPHQL_TRANSPORT_WS_PROTOCOL, GRAPHQL_WS_PROTOCOL
import uvicorn
@ -13,8 +14,12 @@ from selfprivacy_api.migrations import run_migrations
app = FastAPI()
graphql_app = GraphQLRouter(
graphql_app: GraphQLRouter = GraphQLRouter(
schema,
subscription_protocols=[
GRAPHQL_TRANSPORT_WS_PROTOCOL,
GRAPHQL_WS_PROTOCOL,
],
)
app.add_middleware(

View 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