core/schema.graphql

506 lines
9.9 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
type MessageResult {
error: String
message: Message
}
enum MessageStatus {
NEW
UPDATED
DELETED
}
type ChatUpdatedResult {
error: String
status: MessageStatus
message: Message
}
type EnterChatResult {
chat: Chat
messages: [Message]
error: String
}
2022-10-03 23:25:11 +00:00
type ChatResult {
error: String
members: [User]!
createdAt: DateTime!
createdBy: User
messages: [Message]
title: String
2022-05-03 12:55:29 +00:00
}
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
}
type Result {
2022-02-03 09:13:53 +00:00
error: String
shout: Shout
shouts: [Shout]
author: User
authors: [User]
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-02-03 09:13:53 +00:00
slug: String!
body: String!
2022-06-28 19:40:44 +00:00
community: String!
2022-02-03 09:13:53 +00:00
mainTopic: String
topic_slugs: [String]
title: String
subtitle: String
versionOf: String
visibleForRoles: [String] # role ids are strings
visibleForUsers: [Int]
2021-08-21 00:40:41 +00:00
}
input ProfileInput {
2022-02-03 09:13:53 +00:00
name: String
userpic: String
links: [String]
bio: String
2021-08-20 23:17:15 +00:00
}
2021-11-26 00:41:20 +00:00
input CommunityInput {
2022-02-03 09:13:53 +00:00
title: String!
desc: String
pic: String
2021-11-26 00:41:20 +00:00
}
2022-08-11 09:09:57 +00:00
input CollectionInput {
title: String!
desc: String
pic: String
}
input TopicInput {
2022-02-03 09:13:53 +00:00
slug: String!
community: String!
2022-02-03 09:13:53 +00:00
title: String
body: String
pic: String
children: [String]
parents: [String]
2022-01-28 09:49:46 +00:00
}
input ReactionInput {
kind: Int!
shout: String!
range: String
body: String
replyTo: Int
2022-01-28 09:49:46 +00:00
}
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-11-02 09:23:14 +00:00
createChat(description: String): Chat!
2022-10-03 23:43:08 +00:00
inviteChat(chatId: String!, userslug: String!): Result!
2022-08-11 05:53:14 +00:00
createMessage(chatId: String!, body: String!, replyTo: Int): MessageResult!
updateMessage(chatId: String!, id: Int!, body: String!): MessageResult!
deleteMessage(chatId: String!, id: Int!): Result!
markAsRead(chatId: String!, ids: [Int]!): Result!
2022-02-03 09:13:53 +00:00
# auth
2022-08-12 08:13:18 +00:00
refreshSession: AuthResult!
2022-10-20 22:05:37 +00:00
registerUser(email: String!, password: String, name: String): AuthResult!
2022-10-21 05:47:58 +00:00
sendLink(email: String!, lang: String): Result!
2022-10-23 12:48:08 +00:00
confirmEmail(token: String!): AuthResult!
2022-02-03 09:13:53 +00:00
# shout
createShout(input: ShoutInput!): Result!
updateShout(input: ShoutInput!): Result!
2022-02-03 09:13:53 +00:00
deleteShout(slug: String!): Result!
# user profile
2022-02-16 12:38:05 +00:00
rateUser(slug: String!, value: Int!): Result!
2022-02-03 09:13:53 +00:00
# updateOnlineStatus: Result!
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!
updateReaction(reaction: ReactionInput!): Result!
deleteReaction(id: Int!): Result!
2022-02-03 09:13:53 +00:00
2022-06-19 17:54:39 +00:00
# community
createCommunity(community: CommunityInput!): Result!
updateCommunity(community: CommunityInput!): Result!
2022-06-28 19:40:44 +00:00
deleteCommunity(slug: String!): Result!
2022-02-03 09:13:53 +00:00
2022-08-11 09:09:57 +00:00
# collection
createCollection(collection: CollectionInput!): Result!
updateCollection(collection: CollectionInput!): Result!
deleteCollection(slug: String!): Result!
# collab
inviteAuthor(author: String!, shout: String!): Result!
removeAuthor(author: String!, shout: String!): Result!
# following
follow(what: FollowingEntity!, slug: String!): Result!
unfollow(what: FollowingEntity!, slug: String!): Result!
2022-09-08 16:46:02 +00:00
# seen
incrementView(shout: String!): Result!
2021-08-20 23:17:15 +00:00
}
################################### Query
type Query {
2022-08-11 05:53:14 +00:00
# inbox
2022-10-03 23:25:11 +00:00
myChats: [ChatResult]!
enterChat(chatId: String!): ChatResult!
loadChat(chatId: String!, size: Int!, page: Int!): [Message]!
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
# profile
getUsersBySlugs(slugs: [String]!): [User]!
userFollowers(slug: String!): [User]!
userFollowedAuthors(slug: String!): [User]!
userFollowedTopics(slug: String!): [Topic]!
userFollowedCommunities(slug: String!): [Community]!
userReactedShouts(slug: String!): [Shout]! # test
2022-02-03 09:13:53 +00:00
getUserRoles(slug: String!): [Role]!
2022-09-30 09:13:04 +00:00
authorsAll: [User]!
2022-04-28 09:04:14 +00:00
2022-02-03 09:13:53 +00:00
# shouts
getShoutBySlug(slug: String!): Shout!
2022-09-14 09:45:31 +00:00
shoutsForFeed(offset: Int!, limit: Int!): [Shout]! # test
2022-10-01 10:25:13 +00:00
shoutsByTopics(slugs: [String]!, offset: Int!, limit: Int!): [Shout]!
2022-09-14 09:45:31 +00:00
shoutsByAuthors(slugs: [String]!, offset: Int!, limit: Int!): [Shout]!
shoutsByCommunities(slugs: [String]!, offset: Int!, limit: Int!): [Shout]!
# topReacted(offset: Int!, limit: Int!): [Shout]!
2022-09-20 13:32:04 +00:00
topAuthors(offset: Int!, limit: Int!): [Author]! # by User.rating
topPublished(daysago: Int!, offset: Int!, limit: Int!): [Shout]!
topMonth(offset: Int!, limit: Int!): [Shout]! # TODO: implement topPublishedAfter(day, offset, limit)
topOverall(offset: Int!, limit: Int!): [Shout]!
topCommented(offset: Int!, limit: Int!): [Shout]!
2022-09-14 09:45:31 +00:00
recentPublished(offset: Int!, limit: Int!): [Shout]! # homepage
2022-09-19 18:42:38 +00:00
recentReacted(offset: Int!, limit: Int!): [Shout]! # TODO: use in design!
2022-09-19 16:14:20 +00:00
recentCommented(offset: Int!, limit: Int!): [Shout]!
2022-09-14 09:45:31 +00:00
recentAll(offset: Int!, limit: Int!): [Shout]!
2022-09-22 10:31:44 +00:00
recentCandidates(offset: Int!, limit: Int!): [Shout]!
# reactons
2022-09-14 09:45:31 +00:00
reactionsByAuthor(slug: String!, offset: Int!, limit: Int!): [Reaction]!
reactionsForShouts(shouts: [String]!, offset: Int!, limit: Int!): [Reaction]!
# collab
2022-09-02 10:23:33 +00:00
getCollabs: [Collab]!
2022-02-03 09:13:53 +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-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]!
2022-08-13 10:05:46 +00:00
# collections
2022-08-17 09:07:32 +00:00
collectionsAll: [Collection]!
2022-08-13 10:05:46 +00:00
getUserCollections(author: String!): [Collection]!
2022-09-14 09:45:31 +00:00
shoutsByCollection(collection: String!, offset: Int!, limit: Int!): [Shout]!
2022-08-11 09:09:57 +00:00
2022-02-03 09:13:53 +00:00
# communities
getCommunity(slug: String): Community!
getCommunities: [Community]! # all
2022-09-05 07:28:23 +00:00
# search
2022-09-14 09:45:31 +00:00
searchQuery(q: String, offset: Int!, limit: Int!): [Shout]
2021-08-20 23:17:15 +00:00
}
############################################ Subscription
type Subscription {
2022-08-11 05:53:14 +00:00
chatUpdated(chatId: String!): ChatUpdatedResult!
2022-02-03 09:13:53 +00:00
onlineUpdated: [User!]!
shoutUpdated: Shout!
userUpdated: User!
reactionUpdated(shout: String!): ReactionUpdating!
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 {
2022-02-03 09:13:53 +00:00
operation_id: Int!
resource_id: 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 Notification {
2022-02-03 09:13:53 +00:00
kind: String! # unique primary key
template: String!
variables: [String]
2021-08-20 23:17:15 +00:00
}
type UserNotification {
2022-02-03 09:13:53 +00:00
id: Int! # primary key
user: Int!
kind: String! # NotificationTemplate.name
values: [String]
2021-08-20 23:17:15 +00:00
}
type User {
2022-02-03 09:13:53 +00:00
id: Int!
username: String! # to login, ex. email
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
notifications: [Int]
communities: [Int] # user participating communities
2022-07-07 13:55:13 +00:00
oid: String
2021-08-20 23:17:15 +00:00
}
2022-09-02 10:23:33 +00:00
type Collab {
authors: [String]!
invites: [String]
createdAt: DateTime!
title: String
body: String
}
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
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
replyTo: Reaction
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
2022-08-05 15:55:07 +00:00
type Author {
slug: String!
2022-08-09 10:17:31 +00:00
name: String!
2022-08-05 15:55:07 +00:00
userpic: String
2022-09-01 10:16:22 +00:00
caption: String # only for full shout
2022-08-22 15:04:47 +00:00
bio: String
2022-08-22 14:56:51 +00:00
links: [String]
2022-08-05 15:55:07 +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!
createdAt: DateTime!
2022-08-09 02:29:30 +00:00
authors: [Author]
2022-09-02 10:23:33 +00:00
lang: String
2022-06-28 19:40:44 +00:00
community: String
2022-02-03 09:13:53 +00:00
cover: String
layout: String
2022-07-07 13:55:13 +00:00
draft: Boolean
versionOf: Shout # translations and adaptations
visibleFor: [User]
2022-02-03 09:13:53 +00:00
topics: [Topic]
mainTopic: String
title: String
subtitle: String
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
publishedBy: User
2022-02-03 09:13:53 +00:00
publishedAt: DateTime
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-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 {
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!
viewed: Int!
reacted: Int!
2022-08-17 07:59:17 +00:00
commented: Int
2022-08-13 16:19:16 +00:00
rating: Int
2021-12-13 16:51:01 +00:00
}
2021-08-20 23:17:15 +00:00
type Topic {
2022-02-03 09:13:53 +00:00
slug: String! # ID
title: String
body: String
pic: String
parents: [String] # NOTE: topic can have parent topics
children: [String] # and children
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 {
author: String!
2022-11-02 09:23:14 +00:00
chatId: Int!
2022-08-11 05:53:14 +00:00
body: String!
createdAt: DateTime!
id: Int!
replyTo: Int
updatedAt: DateTime!
2022-11-02 09:23:14 +00:00
visibleForUsers: [Int]
2022-08-11 05:53:14 +00:00
}
type Chat {
id: Int!
createdAt: DateTime!
2022-10-03 23:25:11 +00:00
createdBy: User!
2022-08-11 05:53:14 +00:00
updatedAt: DateTime!
2022-10-03 23:43:08 +00:00
title: String
2022-08-11 05:53:14 +00:00
description: String
2022-10-03 23:25:11 +00:00
users: [User]!
2022-11-02 09:23:14 +00:00
messages: [Message]!
2022-11-02 09:46:25 +00:00
unread: Int
2022-08-11 05:53:14 +00:00
}