2022-11-15 13:04:55 +00:00
|
|
|
|
|
|
|
import dataclasses
|
|
|
|
import strawberry
|
|
|
|
import strawberry.utils.graphiql
|
|
|
|
|
|
|
|
from socketify import App
|
|
|
|
from typing import List, Optional
|
2022-11-15 13:17:09 +00:00
|
|
|
from helpers.graphiql import graphiql_from
|
2022-11-15 13:04:55 +00:00
|
|
|
|
|
|
|
@strawberry.type
|
|
|
|
class User:
|
|
|
|
name: str
|
|
|
|
|
|
|
|
@strawberry.type
|
|
|
|
class Query:
|
|
|
|
@strawberry.field
|
|
|
|
def user(self) -> Optional[User]:
|
|
|
|
return User(name="Hello")
|
|
|
|
|
|
|
|
|
|
|
|
app = App()
|
|
|
|
app.get("/", lambda res, req: res.end(strawberry.utils.graphiql.get_graphiql_html()))
|
2022-11-15 13:17:09 +00:00
|
|
|
app.post("/", graphiql_from(Query))
|
2022-11-15 13:04:55 +00:00
|
|
|
app.listen(3000, lambda config: print("Listening on port http://localhost:%d now\n" % config.port))
|
|
|
|
app.run()
|