core/schema.graphql

503 lines
9.1 KiB
GraphQL
Raw Normal View History

2021-08-20 23:17:15 +00:00
scalar DateTime
################################### Payload ###################################
2021-08-20 23:17:15 +00:00
2022-08-11 05:53:14 +00:00
enum MessageStatus {
NEW
UPDATED
DELETED
}
2022-10-04 12:07:41 +00:00
type UserFollowings {
2022-08-12 12:50:59 +00:00
unread: Int
topics: [String]
authors: [String]
reactions: [Int]
communities: [String]
}
2021-08-20 23:17:15 +00:00
type AuthResult {
2022-02-03 09:13:53 +00:00
error: String
token: String
user: User
2022-10-04 12:07:41 +00:00
news: UserFollowings
2021-08-20 23:17:15 +00:00
}
2022-11-02 10:00:04 +00:00
type ChatMember {
2022-11-21 08:13:57 +00:00
id: Int!
2022-11-02 10:00:04 +00:00
slug: String!
name: String!
2022-11-12 18:13:23 +00:00
userpic: String
2022-11-21 08:13:57 +00:00
lastSeen: DateTime
2022-12-04 14:03:55 +00:00
online: Boolean
2022-11-27 12:12:08 +00:00
# invitedAt: DateTime
# invitedBy: String # user slug
# TODO: keep invite databit
2022-11-02 10:00:04 +00:00
}
2022-11-13 04:21:09 +00:00
type AuthorStat {
followings: Int
followers: Int
rating: Int
2022-11-13 15:24:29 +00:00
commented: Int
2022-11-19 11:35:34 +00:00
shouts: Int
2022-11-13 04:21:09 +00:00
}
2022-11-12 18:13:23 +00:00
type Author {
2022-11-13 04:21:09 +00:00
id: Int!
2022-11-12 18:13:23 +00:00
slug: String!
2022-11-13 04:21:09 +00:00
name: String!
2022-11-12 18:13:23 +00:00
userpic: String
2022-11-13 04:21:09 +00:00
caption: String # only for full shout
bio: String
2022-12-09 05:54:26 +00:00
about: String
2022-11-13 04:21:09 +00:00
links: [String]
2022-11-12 18:13:23 +00:00
stat: AuthorStat
roles: [Role] # in different communities
lastSeen: DateTime
createdAt: DateTime
2022-11-12 18:13:23 +00:00
}
type Result {
2022-02-03 09:13:53 +00:00
error: String
2022-11-11 21:27:17 +00:00
slugs: [String]
2022-11-02 10:00:04 +00:00
chat: Chat
chats: [Chat]
message: Message
messages: [Message]
members: [ChatMember]
shout: Shout
shouts: [Shout]
2022-11-12 18:13:23 +00:00
author: Author
authors: [Author]
reaction: Reaction
reactions: [Reaction]
topic: Topic
topics: [Topic]
community: Community
communities: [Community]
}
enum ReactionStatus {
NEW
UPDATED
CHANGED
EXPLAINED
DELETED
}
type ReactionUpdating {
error: String
status: ReactionStatus
reaction: Reaction
2021-08-20 23:17:15 +00:00
}
################################### Inputs ###################################
2021-08-20 23:17:15 +00:00
input ShoutInput {
2022-11-24 16:26:12 +00:00
slug: String
title: String
2023-05-03 15:47:09 +00:00
body: String
lead: String
description: String
layout: String
media: String
2022-11-24 16:26:12 +00:00
authors: [String]
2023-05-11 11:03:14 +00:00
topics: [TopicInput]
2022-11-24 16:26:12 +00:00
community: Int
2023-05-11 11:03:14 +00:00
mainTopic: TopicInput
2022-02-03 09:13:53 +00:00
subtitle: String
cover: String
2021-08-21 00:40:41 +00:00
}
input ProfileInput {
2022-12-02 08:47:55 +00:00
slug: String
2022-02-03 09:13:53 +00:00
name: String
userpic: String
links: [String]
bio: String
2022-12-02 08:47:55 +00:00
about: String
2021-08-20 23:17:15 +00:00
}
input TopicInput {
2023-05-11 11:03:14 +00:00
id: Int,
2022-02-03 09:13:53 +00:00
slug: String!
2023-05-11 11:03:14 +00:00
# community: String!
2022-02-03 09:13:53 +00:00
title: String
body: String
pic: String
2022-11-19 13:18:17 +00:00
# children: [String]
# parents: [String]
2022-01-28 09:49:46 +00:00
}
2023-01-13 11:04:45 +00:00
input ReactionInput {
2022-12-23 14:45:00 +00:00
kind: ReactionKind!
shout: Int!
range: String
body: String
replyTo: Int
2022-01-28 09:49:46 +00:00
}
2022-11-02 13:36:10 +00:00
input ChatInput {
id: String!
title: String
description: String
}
enum FollowingEntity {
TOPIC
AUTHOR
COMMUNITY
REACTIONS
}
2021-08-20 23:17:15 +00:00
################################### Mutation
type Mutation {
2022-08-11 05:53:14 +00:00
# inbox
2022-12-02 11:06:20 +00:00
createChat(title: String, members: [Int]!): Result!
2022-11-02 13:36:10 +00:00
updateChat(chat: ChatInput!): Result!
2022-11-12 07:13:51 +00:00
deleteChat(chatId: String!): Result!
2022-11-15 02:36:30 +00:00
2022-11-28 13:15:52 +00:00
createMessage(chat: String!, body: String!, replyTo: Int): Result!
2022-11-02 10:00:04 +00:00
updateMessage(chatId: String!, id: Int!, body: String!): Result!
2022-08-11 05:53:14 +00:00
deleteMessage(chatId: String!, id: Int!): Result!
markAsRead(chatId: String!, ids: [Int]!): Result!
2022-02-03 09:13:53 +00:00
# auth
2022-11-24 15:19:58 +00:00
getSession: AuthResult!
2022-10-20 22:05:37 +00:00
registerUser(email: String!, password: String, name: String): AuthResult!
2022-11-27 13:14:17 +00:00
sendLink(email: String!, lang: String, template: String): Result!
2022-10-23 12:48:08 +00:00
confirmEmail(token: String!): AuthResult!
2022-02-03 09:13:53 +00:00
# shout
2022-11-24 16:26:12 +00:00
createShout(inp: ShoutInput!): Result!
2023-05-08 17:06:01 +00:00
updateShout(shout_id: Int!, shout_input: ShoutInput, publish: Boolean): Result!
deleteShout(shout_id: Int!): Result!
2022-02-03 09:13:53 +00:00
# user profile
2022-02-16 12:38:05 +00:00
rateUser(slug: String!, value: Int!): Result!
2022-11-15 02:36:30 +00:00
updateOnlineStatus: Result!
2022-02-03 09:13:53 +00:00
updateProfile(profile: ProfileInput!): Result!
# topics
createTopic(input: TopicInput!): Result!
# TODO: mergeTopics(t1: String!, t2: String!): Result!
updateTopic(input: TopicInput!): Result!
destroyTopic(slug: String!): Result!
2022-02-03 09:13:53 +00:00
# reactions
2022-09-08 08:55:48 +00:00
createReaction(reaction: ReactionInput!): Result!
2023-02-06 13:15:47 +00:00
updateReaction(id: Int!, reaction: ReactionInput!): Result!
deleteReaction(id: Int!): Result!
2022-02-03 09:13:53 +00:00
# following
follow(what: FollowingEntity!, slug: String!): Result!
unfollow(what: FollowingEntity!, slug: String!): Result!
2022-11-15 02:36:30 +00:00
}
2022-11-15 09:34:12 +00:00
input MessagesBy {
2022-11-15 02:36:30 +00:00
author: String
body: String
chat: String
2022-11-15 09:34:12 +00:00
order: String
days: Int
stat: String
2021-08-20 23:17:15 +00:00
}
2022-11-15 09:34:12 +00:00
input AuthorsBy {
2022-11-15 02:36:30 +00:00
lastSeen: DateTime
createdAt: DateTime
slug: String
name: String
topic: String
2022-11-15 09:34:12 +00:00
order: String
days: Int
stat: String
2022-11-15 02:36:30 +00:00
}
input LoadShoutsFilters {
title: String
body: String
topic: String
author: String
layout: String
2023-10-01 17:27:08 +00:00
excludeLayout: String
visibility: String
days: Int
reacted: Boolean
}
input LoadShoutsOptions {
filters: LoadShoutsFilters
with_author_captions: Boolean
limit: Int!
offset: Int
order_by: String
order_by_desc: Boolean
2022-11-15 02:36:30 +00:00
}
2022-11-15 09:34:12 +00:00
input ReactionBy {
2022-11-22 18:48:28 +00:00
shout: String # slug
2022-11-15 15:20:44 +00:00
shouts: [String]
2022-11-22 18:48:28 +00:00
search: String # fts on body
comment: Boolean
topic: String # topic.slug
createdBy: String # user.slug
days: Int # before
sort: String # how to sort, default createdAt
2022-11-15 02:36:30 +00:00
}
2021-08-20 23:17:15 +00:00
################################### Query
type Query {
2022-08-11 05:53:14 +00:00
# inbox
2022-11-16 07:32:24 +00:00
loadChats( limit: Int, offset: Int): Result! # your chats
loadMessagesBy(by: MessagesBy!, limit: Int, offset: Int): Result!
2022-11-21 08:13:57 +00:00
loadRecipients(limit: Int, offset: Int): Result!
searchRecipients(query: String!, limit: Int, offset: Int): Result!
2022-12-05 09:48:21 +00:00
searchMessages(by: MessagesBy!, limit: Int, offset: Int): Result!
2022-07-13 15:53:06 +00:00
2022-02-03 09:13:53 +00:00
# auth
2022-06-15 12:41:28 +00:00
isEmailUsed(email: String!): Boolean!
2022-10-21 05:47:58 +00:00
signIn(email: String!, password: String, lang: String): AuthResult!
signOut: AuthResult!
2022-02-03 09:13:53 +00:00
2022-11-15 02:36:30 +00:00
# zine
2022-11-16 07:32:24 +00:00
loadAuthorsBy(by: AuthorsBy, limit: Int, offset: Int): [Author]!
2023-05-08 17:06:01 +00:00
loadShout(slug: String, shout_id: Int): Shout
loadShouts(options: LoadShoutsOptions): [Shout]!
2023-05-04 22:59:04 +00:00
loadDrafts: [Shout]!
2022-11-16 07:32:24 +00:00
loadReactionsBy(by: ReactionBy!, limit: Int, offset: Int): [Reaction]!
2022-11-12 18:13:23 +00:00
userFollowers(slug: String!): [Author]!
userFollowedAuthors(slug: String!): [Author]!
userFollowedTopics(slug: String!): [Topic]!
2022-11-12 18:13:23 +00:00
authorsAll: [Author]!
2023-10-05 17:34:23 +00:00
getAuthor(slug: String!): Author
2023-02-16 10:08:55 +00:00
myFeed(options: LoadShoutsOptions): [Shout]
2022-04-28 09:04:14 +00:00
2022-10-05 09:32:48 +00:00
# migrate
markdownBody(body: String!): String!
2022-02-03 09:13:53 +00:00
# topics
2022-11-18 02:19:10 +00:00
getTopic(slug: String!): Topic
2022-09-05 13:50:09 +00:00
topicsAll: [Topic]!
2022-09-06 16:02:05 +00:00
topicsRandom(amount: Int): [Topic]!
2022-02-03 09:13:53 +00:00
topicsByCommunity(community: String!): [Topic]!
topicsByAuthor(author: String!): [Topic]!
2021-08-20 23:17:15 +00:00
}
############################################ Subscription
type Subscription {
2022-12-07 18:51:38 +00:00
newMessage: Message # new messages in inbox
2023-01-31 16:51:48 +00:00
newShout: Shout # personal feed new shout
newReaction: Reaction # new reactions to notify
2021-08-20 23:17:15 +00:00
}
############################################ Entities
2021-11-24 09:09:47 +00:00
type Resource {
2022-02-03 09:13:53 +00:00
id: Int!
name: String!
2021-11-24 09:09:47 +00:00
}
type Operation {
2022-02-03 09:13:53 +00:00
id: Int!
name: String!
2021-11-24 09:09:47 +00:00
}
type Permission {
operation: Int!
resource: Int!
2021-11-24 09:09:47 +00:00
}
2021-08-20 23:17:15 +00:00
type Role {
2022-02-03 09:13:53 +00:00
id: Int!
name: String!
2022-06-28 19:40:44 +00:00
community: String!
2022-02-03 09:13:53 +00:00
desc: String
permissions: [Permission!]!
2021-08-20 23:17:15 +00:00
}
type Rating {
2022-02-03 09:13:53 +00:00
rater: String!
value: Int!
2022-01-11 13:33:25 +00:00
}
2021-08-20 23:17:15 +00:00
type User {
2022-02-03 09:13:53 +00:00
id: Int!
2022-11-10 05:40:32 +00:00
username: String! # to login, ex. email, phone
2022-02-03 09:13:53 +00:00
createdAt: DateTime!
2022-08-12 12:50:59 +00:00
lastSeen: DateTime
2022-02-03 09:13:53 +00:00
slug: String!
name: String # to display
email: String
password: String
oauth: String # provider:token
userpic: String
links: [String]
emailConfirmed: Boolean # should contain all emails too
muted: Boolean
updatedAt: DateTime
ratings: [Rating]
bio: String
2022-12-09 05:54:26 +00:00
about: String
2022-02-03 09:13:53 +00:00
communities: [Int] # user participating communities
2022-07-07 13:55:13 +00:00
oid: String
2021-08-20 23:17:15 +00:00
}
enum ReactionKind {
LIKE
DISLIKE
AGREE
DISAGREE
PROOF
DISPROOF
2022-09-01 10:16:22 +00:00
COMMENT
2022-07-25 09:34:57 +00:00
QUOTE
2022-09-01 10:16:22 +00:00
PROPOSE
ASK
2022-09-01 10:16:22 +00:00
2023-01-17 19:56:48 +00:00
REMARK
FOOTNOTE
ACCEPT
REJECT
}
type Reaction {
2022-02-03 09:13:53 +00:00
id: Int!
shout: Shout!
2022-02-03 09:13:53 +00:00
createdAt: DateTime!
createdBy: User!
2022-02-03 09:13:53 +00:00
updatedAt: DateTime
deletedAt: DateTime
2022-07-07 13:55:13 +00:00
deletedBy: User
range: String # full / 0:2340
kind: ReactionKind!
body: String
2022-11-28 13:15:52 +00:00
replyTo: Int
stat: Stat
old_id: String
2022-02-03 09:13:53 +00:00
old_thread: String
2021-10-13 17:46:30 +00:00
}
2021-09-03 16:01:31 +00:00
2021-08-20 23:17:15 +00:00
# is publication
type Shout {
2022-06-14 06:13:06 +00:00
id: Int!
2022-02-03 09:13:53 +00:00
slug: String!
body: String!
lead: String
2023-08-21 11:30:18 +00:00
description: String
2022-02-03 09:13:53 +00:00
createdAt: DateTime!
topics: [Topic]
mainTopic: String
title: String
subtitle: String
2022-11-13 04:07:52 +00:00
authors: [Author]
lang: String
community: String
cover: String
layout: String # audio video literature image
versionOf: String # for translations and re-telling the same story
visibility: String # owner authors community public
2022-02-03 09:13:53 +00:00
updatedAt: DateTime
2022-07-07 13:55:13 +00:00
updatedBy: User
2022-02-03 09:13:53 +00:00
deletedAt: DateTime
2022-07-07 13:55:13 +00:00
deletedBy: User
2022-02-03 09:13:53 +00:00
publishedAt: DateTime
2022-11-26 14:58:53 +00:00
media: String # json [ { title pic url body }, .. ]
stat: Stat
2021-12-17 10:22:31 +00:00
}
type Stat {
viewed: Int
reacted: Int
rating: Int
2022-08-17 07:59:17 +00:00
commented: Int
2022-09-05 07:28:23 +00:00
ranking: Int
2021-08-20 23:17:15 +00:00
}
2021-08-26 21:14:20 +00:00
type Community {
2022-11-10 05:40:32 +00:00
id: Int!
2022-02-03 09:13:53 +00:00
slug: String!
name: String!
desc: String
pic: String!
createdAt: DateTime!
createdBy: User!
2021-08-26 21:14:20 +00:00
}
2022-08-11 09:09:57 +00:00
type Collection {
2022-11-10 05:40:32 +00:00
id: Int!
2022-08-11 09:09:57 +00:00
slug: String!
title: String!
desc: String
2022-08-17 09:07:32 +00:00
amount: Int
2022-08-13 10:05:46 +00:00
publishedAt: DateTime
2022-08-11 09:09:57 +00:00
createdAt: DateTime!
createdBy: User!
}
2021-12-13 16:51:01 +00:00
type TopicStat {
2022-02-03 09:13:53 +00:00
shouts: Int!
followers: Int!
2022-02-03 09:13:53 +00:00
authors: Int!
2022-11-21 08:13:57 +00:00
# viewed: Int
2022-11-23 13:34:34 +00:00
# reacted: Int!
2022-11-23 14:09:35 +00:00
# commented: Int
2022-11-23 13:34:34 +00:00
# rating: Int
2021-12-13 16:51:01 +00:00
}
2021-08-20 23:17:15 +00:00
type Topic {
2023-03-27 14:46:14 +00:00
id: Int!
slug: String!
2022-02-03 09:13:53 +00:00
title: String
body: String
pic: String
2023-05-11 11:03:14 +00:00
# community: Community!
2022-07-13 15:53:06 +00:00
stat: TopicStat
2022-07-07 13:55:13 +00:00
oid: String
2021-08-20 23:17:15 +00:00
}
type Token {
2022-02-03 09:13:53 +00:00
createdAt: DateTime!
expiresAt: DateTime
id: Int!
ownerId: Int!
usedAt: DateTime
value: String!
2021-08-28 10:13:50 +00:00
}
2022-08-11 05:53:14 +00:00
type Message {
2022-12-04 11:16:41 +00:00
author: Int!
2022-11-02 13:36:10 +00:00
chatId: String!
2022-08-11 05:53:14 +00:00
body: String!
2022-11-02 13:36:10 +00:00
createdAt: Int!
2022-08-11 05:53:14 +00:00
id: Int!
2022-12-10 07:35:29 +00:00
replyTo: Int
2022-11-02 13:36:10 +00:00
updatedAt: Int
2022-12-07 07:49:43 +00:00
seen: Boolean
2022-08-11 05:53:14 +00:00
}
type Chat {
2022-11-08 15:50:28 +00:00
id: String!
2022-11-02 13:36:10 +00:00
createdAt: Int!
createdBy: Int!
2022-11-02 13:36:10 +00:00
updatedAt: Int!
2022-10-03 23:43:08 +00:00
title: String
2022-08-11 05:53:14 +00:00
description: String
users: [Int]
2022-11-27 12:12:08 +00:00
members: [ChatMember]
admins: [Int]
messages: [Message]
2022-11-02 09:46:25 +00:00
unread: Int
2022-11-11 21:27:17 +00:00
private: Boolean
2022-08-11 05:53:14 +00:00
}