graph2: Added Post type and queries

This commit is contained in:
2018-09-15 09:29:04 +02:00
parent 1be4088a8f
commit 0444911e73
6 changed files with 127 additions and 2 deletions
+5 -1
View File
@@ -20,4 +20,8 @@ models:
Channel:
model: git.aiterp.net/rpdata/api/model/channel.Channel
ChannelsFilter:
model: git.aiterp.net/rpdata/api/model/channel.Filter
model: git.aiterp.net/rpdata/api/model/channel.Filter
Post:
model: git.aiterp.net/rpdata/api/model/log.Post
Date:
model: git.aiterp.net/rpdata/api/model/scalars.Date
+15
View File
@@ -0,0 +1,15 @@
package queries
import (
"context"
"git.aiterp.net/rpdata/api/model/log"
)
func (r *resolver) Post(ctx context.Context, id string) (log.Post, error) {
return log.FindPostID(id)
}
func (r *resolver) Posts(ctx context.Context, ids []string) ([]log.Post, error) {
return log.ListPostIDs(ids...)
}
+10
View File
@@ -17,7 +17,17 @@ type Query {
channels(filter: ChannelsFilter): [Channel!]!
# Find post by ID.
post(id: String!): Post!
# Find posts by IDs. It's meant to allow other parts of the UI to link to a cluster of posts, e.g. for a room description for the
# Mapp should it ever become a thing. This does not have a filter, since it's meant to be queried in the logs' response's selection set.
posts(ids: [String!]!): [Post!]!
# Find all distinct tags used in stories
tags: [Tag!]!
}
scalar Date
+68
View File
@@ -0,0 +1,68 @@
# A Post is a part of a log
type Post {
# The post's ID
id: String!
# The post's Log ID. This is the closest thing to a link back since this API graph doesn't have any cycles.
logId: String!
# The date and time of posting
time: Date!
# The kind of post this is. Only "text", "scene" and "action" are RP, while others are annotations and 'commands'.
kind: String!
# The character nick
nick: String!
# The post's text, which purpose depends on the kind
text: String!
# The post's position, used for reordering
position: Int!
}
# Input for the addPost mutation
input AddPostInput {
# The log's ID that this post should be a part of
logId: String!
# The date and time of posting, in a RFC3339 format with up to a nanosecond's precision
time: Date!
# The kind of post this is. Only "text", "scene" and "action" are RP, while others are annotations and 'commands'.
kind: String!
# The character nick, or command invoker for non-RP stuff
nick: String!
# The post's text, which purpose depends on the kind
text: String!
}
# Input for the editPost mutation
input EditPostInput {
# The Post ID
id: String!
# The date and time of posting, in a RFC3339 format with up to a nanosecond's precision
time: Date
# The kind of post this is. Only "text", "scene" and "action" are RP, while others are annotations and 'commands'.
kind: String
# The character nick, or command invoker for non-RP stuff
nick: String
# The post's text, which purpose depends on the kind
text: String
}
# Input for the movePost mutation
input MovePostInput {
# The Post ID
id: String!
# Target index
toPosition: Int!
}