add nextLogs and prevLogs suggestions to log.

This commit is contained in:
2020-08-09 15:35:49 +02:00
parent 757b0bc616
commit 47b7877ab4
7 changed files with 146 additions and 0 deletions
+6
View File
@@ -164,6 +164,12 @@ func complexity() (cr graphcore.ComplexityRoot) {
cr.Log.Posts = func(childComplexity int, kinds []string) int {
return childComplexity + hugeSublistComplexity
}
cr.Log.NextLogs = func(childComplexity int) int {
return childComplexity + (subListComplexity / 2)
}
cr.Log.PrevLogs = func(childComplexity int) int {
return childComplexity + (subListComplexity / 2)
}
cr.Story.Chapters = func(childComplexity int) int {
return childComplexity + bigSublistComplexity
+2
View File
@@ -37,6 +37,8 @@ models:
model: git.aiterp.net/rpdata/api/models.LogFilter
LogImporter:
model: git.aiterp.net/rpdata/api/models.LogImporter
LogSuggestion:
model: git.aiterp.net/rpdata/api/models.LogSuggestion
Comment:
model: git.aiterp.net/rpdata/api/models.Comment
ChapterCommentMode:
+14
View File
@@ -34,6 +34,20 @@ type Log {
# The posts of the logfile, which can be filtered by kinds.
posts(kinds:[String!]): [Post!]!
# Suggested next logs.
nextLogs: [LogSuggestion!]!
# Suggested previous logs.
prevLogs: [LogSuggestion!]!
}
# Suggested log
type LogSuggestion {
log: Log!
hasEvent: Boolean!
hasChannel: Boolean!
characters: [Character!]!
}
# Filter for logs query
+8
View File
@@ -31,6 +31,14 @@ func (r *logResolver) Posts(ctx context.Context, log *models.Log, kinds []string
return r.logs.ListPosts(ctx, &models.PostFilter{LogID: &log.ShortID})
}
func (r *logResolver) NextLogs(ctx context.Context, obj *models.Log) ([]*models.LogSuggestion, error) {
return r.logs.NextLogs(ctx, obj)
}
func (r *logResolver) PrevLogs(ctx context.Context, obj *models.Log) ([]*models.LogSuggestion, error) {
return r.logs.PrevLogs(ctx, obj)
}
// LogResolver is a resolver
func LogResolver(s *services.Bundle) *logResolver {
return &logResolver{characters: s.Characters, logs: s.Logs, channels: s.Channels}