core/schema.graphql

242 lines
4.8 KiB
GraphQL
Raw Normal View History

2021-08-20 23:17:15 +00:00
scalar DateTime
################################### Payload
type Result {
2021-08-21 00:40:41 +00:00
error: String
2021-08-20 23:17:15 +00:00
}
type AuthResult {
2021-08-21 00:40:41 +00:00
error: String
token: String
user: User
2021-08-20 23:17:15 +00:00
}
type UserResult {
2021-08-21 00:40:41 +00:00
error: String
user: User
2021-08-20 23:17:15 +00:00
}
type MessageResult {
2021-08-21 00:40:41 +00:00
error: String
message: Message
2021-08-20 23:17:15 +00:00
}
input ShoutInput {
2021-08-21 00:40:41 +00:00
org_id: Int!
slug: String!
body: String!
replyTo: String # another shout
tags: [String] # actual values
topics: [String] # topic-slugs
title: String
versionOf: String
visibleForRoles: [String] # role ids are strings
visibleForUsers: [Int]
}
input ProfileInput {
2021-08-20 23:17:15 +00:00
email: String
username: String
userpic: String
}
type ShoutResult {
2021-08-21 00:40:41 +00:00
error: String
shout: Shout
2021-08-20 23:17:15 +00:00
}
################################### Mutation
type Mutation {
# message
2021-08-21 00:40:41 +00:00
createMessage(body: String!, replyTo: Int): MessageResult!
updateMessage(id: Int!, body: String!): MessageResult!
deleteMessage(messageId: Int!): Result!
2021-08-20 23:17:15 +00:00
# auth
confirmEmail(token: String!): AuthResult!
requestPasswordReset(email: String!): Boolean!
confirmPasswordReset(token: String!): Boolean!
2021-08-25 08:31:51 +00:00
registerUser(email: String!, password: String): AuthResult!
2021-08-20 23:17:15 +00:00
# updatePassword(password: String!, token: String!): Token!
# invalidateAllTokens: Boolean!
# invalidateTokenById(id: Int!): Boolean!
# requestEmailConfirmation: User!
# shout
2021-08-21 00:40:41 +00:00
createShout(input: ShoutInput!): ShoutResult!
updateShout(input: ShoutInput!): ShoutResult!
deleteShout(slug: String!): Result!
rateShout(slug: String!, value: Int!): Result!
2021-08-20 23:17:15 +00:00
# user profile
# rateUser(value: Int!): Result!
# updateOnlineStatus: Result!
updateProfile(profile: ProfileInput!): Result!
}
################################### Query
type Query {
# auth
2021-08-21 00:40:41 +00:00
isEmailFree(email: String!): Result!
2021-08-25 17:12:01 +00:00
signIn(email: String!, password: String): AuthResult!
2021-08-21 00:40:41 +00:00
signOut: Result!
2021-08-20 23:17:15 +00:00
# user profile
2021-08-21 00:40:41 +00:00
getCurrentUser: UserResult!
2021-08-20 23:17:15 +00:00
getUserById(id: Int!): UserResult!
# getUserRating(shout: Int): Int!
# messages
getMessages(count: Int = 100, page: Int = 1): [Message!]!
# shouts
# getShoutRating(shout: Int): Int!
# shoutsByAuthor(author: Int): [Shout]!
# shoutsByReplyTo(shout: Int): [Shout]!
# shoutsByTags(tags: [String]): [Shout]!
# shoutsByTime(time: DateTime): [Shout]!
# getOnlineUsers: [User!]!
2021-08-21 00:40:41 +00:00
topAuthors: [User]!
topShouts: [Shout]!
2021-08-20 23:17:15 +00:00
}
############################################ Subscription
type Subscription {
messageCreated: Message!
messageUpdated: Message!
messageDeleted: Message!
2021-08-21 00:40:41 +00:00
2021-08-20 23:17:15 +00:00
onlineUpdated: [User!]!
shoutUpdated: Shout!
userUpdated: User!
}
############################################ Entities
type Role {
id: Int!
name: String!
2021-08-26 21:14:20 +00:00
community: Int!
2021-08-20 23:17:15 +00:00
desc: String
permissions: [Int!]!
}
type Rating {
2021-08-20 23:18:10 +00:00
createdBy: Int!
2021-08-20 23:17:15 +00:00
value: Int!
}
type Notification {
kind: String! # unique primary key
template: String!
variables: [String]
}
type UserNotification {
id: Int! # primary key
user: Int!
kind: String! # NotificationTemplate.name
values: [String]
}
type User {
2021-08-23 08:44:46 +00:00
id: Int!
2021-08-20 23:17:15 +00:00
username: String! # email
createdAt: DateTime!
2021-08-23 08:44:46 +00:00
slug: String!
viewname: String # to display
2021-08-20 23:17:15 +00:00
email: String
password: String
oauth: String # provider:token
userpic: String
links: [String]
emailConfirmed: Boolean # should contain all emails too # TODO: pagination here
muted: Boolean
rating: Int
roles: [Role]
updatedAt: DateTime
wasOnlineAt: DateTime
ratings: [Rating]
bio: String
2021-08-21 00:40:41 +00:00
notifications: [Int]
2021-08-26 21:14:20 +00:00
topics: [String] # user subscribed topics
communities: [Int] # user participating communities
2021-08-20 23:17:15 +00:00
}
type Message {
author: Int!
body: String!
createdAt: DateTime!
id: Int!
replyTo: Int
updatedAt: DateTime!
visibleForUsers: [Int]!
}
# is publication
type Shout {
authors: [Int!]!
2021-08-26 21:14:20 +00:00
slug: String!
2021-08-20 23:18:10 +00:00
body: String!
2021-08-20 23:17:15 +00:00
createdAt: DateTime!
2021-08-20 23:18:10 +00:00
updatedAt: DateTime!
2021-08-26 21:14:20 +00:00
community: Int
cover: String
layout: String
2021-08-20 23:17:15 +00:00
deletedAt: DateTime
deletedBy: Int
rating: Int
ratigns: [Rating]
2021-08-21 00:40:41 +00:00
published: Boolean!
2021-08-20 23:17:15 +00:00
publishedAt: DateTime # if there is no published field - it is not published
2021-08-26 21:14:20 +00:00
replyTo: Int # another shout
2021-08-20 23:17:15 +00:00
tags: [String] # actual values
topics: [String] # topic-slugs, order has matter
title: String
2021-08-25 21:20:53 +00:00
subtitle: String
2021-08-20 23:17:15 +00:00
versionOf: String
visibleForRoles: [String] # role ids are strings
visibleForUsers: [Int]
views: Int
2021-08-25 21:20:53 +00:00
old_id: String
2021-08-20 23:17:15 +00:00
}
2021-08-26 21:14:20 +00:00
type Community {
slug: String!
name: String!
desc: String
pic: String!
}
2021-08-20 23:17:15 +00:00
type Topic {
slug: String! # ID
createdBy: Int! # User
createdAt: DateTime!
value: String
desc: String
parents: [String] # NOTE: topic can have parent topics
children: [String] # and children
}
# TODO: resolvers to add/remove topics from publication
type Proposal {
body: String!
shout: Int!
range: String # full / 0:2340
author: Int!
createdAt: DateTime!
}
type Token {
createdAt: DateTime!
expiresAt: DateTime
id: Int!
ownerId: Int!
usedAt: DateTime
value: String!
2021-08-26 21:14:20 +00:00
}