fix
This commit is contained in:
13
main.py
13
main.py
@@ -193,6 +193,12 @@ class Query:
|
|||||||
stmt = select(User)
|
stmt = select(User)
|
||||||
return UsersGQL(users=[json.dumps(user.to_dict()) for user in session.scalars(stmt)])
|
return UsersGQL(users=[json.dumps(user.to_dict()) for user in session.scalars(stmt)])
|
||||||
|
|
||||||
|
@strawberry.field()
|
||||||
|
def user(self, id: int) -> UsersGQL:
|
||||||
|
sync_engine = connect()
|
||||||
|
with Session(sync_engine) as session:
|
||||||
|
return UsersGQL(users=json.dumps(session.query(User).filter(User.id == id).one_or_none().to_dict()))
|
||||||
|
|
||||||
@strawberry.field()
|
@strawberry.field()
|
||||||
def queue(self) -> UsersGQL:
|
def queue(self) -> UsersGQL:
|
||||||
sync_engine = connect()
|
sync_engine = connect()
|
||||||
@@ -204,14 +210,17 @@ class Query:
|
|||||||
@strawberry.type
|
@strawberry.type
|
||||||
class Mutation:
|
class Mutation:
|
||||||
@strawberry.mutation
|
@strawberry.mutation
|
||||||
def update_user(self, id_: int, bndname: str, newbnd: bool, active: bool, upstream: bool) -> bool:
|
def update_user(self, id_: int, bndname: str, newbnd: bool, active: bool, upstream: bool, passwd: str,
|
||||||
|
username: str) -> bool:
|
||||||
sync_engine = connect()
|
sync_engine = connect()
|
||||||
with Session(sync_engine) as session:
|
with Session(sync_engine) as session:
|
||||||
user = session.query(User).get(id_)
|
user = session.query(User).get(id_)
|
||||||
|
user.username = username
|
||||||
user.bndname = bndname
|
user.bndname = bndname
|
||||||
user.newbnd = newbnd
|
user.newbnd = newbnd
|
||||||
user.active = active
|
user.active = active
|
||||||
user.upstream = upstream
|
user.upstream = upstream
|
||||||
|
user.passwd = passwd
|
||||||
session.commit()
|
session.commit()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -342,7 +351,7 @@ graphql_app = GraphQLRouter(schema, graphiql=True)
|
|||||||
|
|
||||||
app = FastAPI(root_path="/graphql")
|
app = FastAPI(root_path="/graphql")
|
||||||
app.add_middleware(CORSMiddleware,
|
app.add_middleware(CORSMiddleware,
|
||||||
allow_origins=['http://127.0.0.1:3000'],
|
allow_origins=['http://127.0.0.1:3000', 'http://localhost:3000'],
|
||||||
allow_credentials=True,
|
allow_credentials=True,
|
||||||
allow_methods=['*'],
|
allow_methods=['*'],
|
||||||
allow_headers=['*']
|
allow_headers=['*']
|
||||||
|
|||||||
Reference in New Issue
Block a user