From fb779217bcf6208bf97690f3a822ca43ba033ec3 Mon Sep 17 00:00:00 2001 From: Untone Date: Thu, 29 Jul 2021 20:26:15 +0300 Subject: [PATCH] schema update --- auth/validations.py | 2 +- orm/user.py | 6 +++--- schema.graphql | 15 +++++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/auth/validations.py b/auth/validations.py index e63a5e14..38a2f620 100644 --- a/auth/validations.py +++ b/auth/validations.py @@ -21,7 +21,7 @@ class PayLoad(BaseModel): class CreateUser(BaseModel): email: Text - username: Text + username: Optional[Text] # age: Optional[int] # phone: Optional[Text] password: Optional[Text] diff --git a/orm/user.py b/orm/user.py index 4cf99f4b..98822eef 100644 --- a/orm/user.py +++ b/orm/user.py @@ -1,6 +1,6 @@ from typing import List -from sqlalchemy import Column, Integer, String, ForeignKey +from sqlalchemy import Column, Integer, String, relationship from orm import Permission from orm.base import Base @@ -13,8 +13,8 @@ class User(Base): username: str = Column(String, nullable=False, comment="Name") password: str = Column(String, nullable=True, comment="Password") - role_id: int = Column(ForeignKey("role.id"), nullable=True, comment="Role") - + # role_id: list = Column(ForeignKey("role.id"), nullable=True, comment="Roles") + # roles = relationship("Role") TODO: one to many, see schema.graphql oauth_id: str = Column(String, nullable=True) @classmethod diff --git a/schema.graphql b/schema.graphql index c0553e8a..d6bb2883 100644 --- a/schema.graphql +++ b/schema.graphql @@ -4,7 +4,7 @@ scalar DateTime input registerUserInput { email: String! - username: String! + username: String password: String! } @@ -113,7 +113,10 @@ type Subscription { ############################################ Entities type Role { + id: Int! name: String! + org: String! + level: Int! # 1-8 desc: String } @@ -139,7 +142,7 @@ type Message { id: Int! replyTo: Int updatedAt: DateTime! - visibleForUsers: [Int] + visibleForUsers: [Int]! } # is publication @@ -160,17 +163,17 @@ type Shout { topics: [String] # topic-slugs title: String versionOf: Int - visibleForRoles: [String]! # role ids are strings + visibleForRoles: [String] # role ids are strings visibleForUsers: [Int] } type Topic { slug: String! # ID createdBy: Int! # User - original: String + createdAt: DateTime! + value: String parents: [String] # NOTE: topic can have parent topics children: [String] # and children - createdAt: DateTime! } # TODO: resolvers to add/remove topics from publication @@ -196,7 +199,7 @@ type Token { type Like { author: Int! id: Int! + value: Int! shout: Int user: Int - value: Int! }