This commit is contained in:
@@ -39,21 +39,12 @@ models:
|
|||||||
model: git.aiterp.net/rpdata/api/models.LogImporter
|
model: git.aiterp.net/rpdata/api/models.LogImporter
|
||||||
Comment:
|
Comment:
|
||||||
model: git.aiterp.net/rpdata/api/models.Comment
|
model: git.aiterp.net/rpdata/api/models.Comment
|
||||||
fields:
|
|
||||||
fictionalDate:
|
|
||||||
resolver: true
|
|
||||||
ChapterCommentMode:
|
ChapterCommentMode:
|
||||||
model: git.aiterp.net/rpdata/api/models.ChapterCommentMode
|
model: git.aiterp.net/rpdata/api/models.ChapterCommentMode
|
||||||
Chapter:
|
Chapter:
|
||||||
model: git.aiterp.net/rpdata/api/models.Chapter
|
model: git.aiterp.net/rpdata/api/models.Chapter
|
||||||
fields:
|
|
||||||
fictionalDate:
|
|
||||||
resolver: true
|
|
||||||
Story:
|
Story:
|
||||||
model: git.aiterp.net/rpdata/api/models.Story
|
model: git.aiterp.net/rpdata/api/models.Story
|
||||||
fields:
|
|
||||||
fictionalDate:
|
|
||||||
resolver: true
|
|
||||||
StoryCategory:
|
StoryCategory:
|
||||||
model: git.aiterp.net/rpdata/api/models.StoryCategory
|
model: git.aiterp.net/rpdata/api/models.StoryCategory
|
||||||
StoriesFilter:
|
StoriesFilter:
|
||||||
@@ -76,5 +67,3 @@ models:
|
|||||||
model: git.aiterp.net/rpdata/api/models.Token
|
model: git.aiterp.net/rpdata/api/models.Token
|
||||||
User:
|
User:
|
||||||
model: git.aiterp.net/rpdata/api/models.User
|
model: git.aiterp.net/rpdata/api/models.User
|
||||||
Date:
|
|
||||||
model: git.aiterp.net/rpdata/api/models/scalars.Date
|
|
||||||
@@ -167,6 +167,6 @@ type Subscription {
|
|||||||
changes(keys: [ChangeKeyInput!]!): Change!
|
changes(keys: [ChangeKeyInput!]!): Change!
|
||||||
}
|
}
|
||||||
|
|
||||||
# A Date represents a RFC3339 encoded date with up to millisecond precision.
|
# A Time represents a RFC3339 encoded date with up to millisecond precision.
|
||||||
scalar Date
|
scalar Time
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ type Change {
|
|||||||
keys: [ChangeKey!]!
|
keys: [ChangeKey!]!
|
||||||
|
|
||||||
"The date when the change happened."
|
"The date when the change happened."
|
||||||
date: Date
|
date: Time
|
||||||
|
|
||||||
"The changed objects."
|
"The changed objects."
|
||||||
objects: [ChangeObject!]!
|
objects: [ChangeObject!]!
|
||||||
@@ -74,7 +74,7 @@ input ChangesFilter {
|
|||||||
keys: [ChangeKeyInput!]
|
keys: [ChangeKeyInput!]
|
||||||
|
|
||||||
"Only show changes more recent than this date."
|
"Only show changes more recent than this date."
|
||||||
earliestDate: Date
|
earliestDate: Time
|
||||||
|
|
||||||
"Limit the amount of results."
|
"Limit the amount of results."
|
||||||
limit: Int
|
limit: Int
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ type Chapter {
|
|||||||
source: String!
|
source: String!
|
||||||
|
|
||||||
# When the chapter was posted initialy
|
# When the chapter was posted initialy
|
||||||
createdDate: Date!
|
createdDate: Time!
|
||||||
|
|
||||||
# The in-universe date and time of the chapter
|
# The in-universe date and time of the chapter
|
||||||
fictionalDate: Date
|
fictionalDate: Time
|
||||||
|
|
||||||
# The date of edit.
|
# The date of edit.
|
||||||
editedDate: Date!
|
editedDate: Time!
|
||||||
|
|
||||||
"The comment mode."
|
"The comment mode."
|
||||||
commentMode: ChapterCommentMode!
|
commentMode: ChapterCommentMode!
|
||||||
@@ -69,7 +69,7 @@ input ChapterAddInput {
|
|||||||
source: String!
|
source: String!
|
||||||
|
|
||||||
# Optionally, assign a fictional date for the chapter
|
# Optionally, assign a fictional date for the chapter
|
||||||
fictionalDate: Date
|
fictionalDate: Time
|
||||||
|
|
||||||
"The comment mode for the chapter."
|
"The comment mode for the chapter."
|
||||||
commentMode: ChapterCommentMode
|
commentMode: ChapterCommentMode
|
||||||
@@ -87,7 +87,7 @@ input ChapterEditInput {
|
|||||||
source: String
|
source: String
|
||||||
|
|
||||||
# Set the fictional date for a chapter
|
# Set the fictional date for a chapter
|
||||||
fictionalDate: Date
|
fictionalDate: Time
|
||||||
|
|
||||||
# Remove the fictional date for a chapter
|
# Remove the fictional date for a chapter
|
||||||
clearFictionalDate: Boolean
|
clearFictionalDate: Boolean
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ type Comment {
|
|||||||
character: Character
|
character: Character
|
||||||
|
|
||||||
"The fictional (IC) date of the comment."
|
"The fictional (IC) date of the comment."
|
||||||
fictionalDate: Date
|
fictionalDate: Time
|
||||||
|
|
||||||
"The date of creation."
|
"The date of creation."
|
||||||
createdDate: Date!
|
createdDate: Time!
|
||||||
|
|
||||||
"The date of the last edit."
|
"The date of the last edit."
|
||||||
editedDate: Date!
|
editedDate: Time!
|
||||||
|
|
||||||
"The markdown source of the comment."
|
"The markdown source of the comment."
|
||||||
source: String!
|
source: String!
|
||||||
@@ -50,7 +50,7 @@ input CommentAddInput {
|
|||||||
characterId: String
|
characterId: String
|
||||||
|
|
||||||
"Optional in-universe date of the comment."
|
"Optional in-universe date of the comment."
|
||||||
fictionalDate: Date
|
fictionalDate: Time
|
||||||
|
|
||||||
"Optional subject to add to the comment, only shown in some modes."
|
"Optional subject to add to the comment, only shown in some modes."
|
||||||
subject: String
|
subject: String
|
||||||
@@ -73,7 +73,7 @@ input CommentEditInput {
|
|||||||
characterId: String
|
characterId: String
|
||||||
|
|
||||||
"Change the optional in-universe date of the comment."
|
"Change the optional in-universe date of the comment."
|
||||||
fictionalDate: Date
|
fictionalDate: Time
|
||||||
|
|
||||||
"Set to clear the fictional date."
|
"Set to clear the fictional date."
|
||||||
clearFictionalDate: Boolean
|
clearFictionalDate: Boolean
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type File {
|
|||||||
kind: String!
|
kind: String!
|
||||||
|
|
||||||
# The time of uploading
|
# The time of uploading
|
||||||
time: Date!
|
time: Time!
|
||||||
|
|
||||||
# Whether the file is publicly listable. Someone with knowledge of the ID
|
# Whether the file is publicly listable. Someone with knowledge of the ID
|
||||||
# will still be able to view it, however.
|
# will still be able to view it, however.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ type Log {
|
|||||||
shortId: String!
|
shortId: String!
|
||||||
|
|
||||||
# The date for a log.
|
# The date for a log.
|
||||||
date: Date!
|
date: Time!
|
||||||
|
|
||||||
# The channel of a log.
|
# The channel of a log.
|
||||||
channelName: String!
|
channelName: String!
|
||||||
@@ -60,7 +60,7 @@ input LogsFilter {
|
|||||||
# Input for addLog mutation
|
# Input for addLog mutation
|
||||||
input LogAddInput {
|
input LogAddInput {
|
||||||
# The date of the log.
|
# The date of the log.
|
||||||
date: Date!
|
date: Time!
|
||||||
|
|
||||||
# The channel where the log is set
|
# The channel where the log is set
|
||||||
channel: String!
|
channel: String!
|
||||||
@@ -116,7 +116,7 @@ input LogImportInput {
|
|||||||
timezone: String
|
timezone: String
|
||||||
|
|
||||||
"The date of the log, if not provided in the log body."
|
"The date of the log, if not provided in the log body."
|
||||||
date: Date
|
date: Time
|
||||||
|
|
||||||
"The log body itself."
|
"The log body itself."
|
||||||
data: String!
|
data: String!
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type Post {
|
|||||||
logId: String!
|
logId: String!
|
||||||
|
|
||||||
# The date and time of posting
|
# The date and time of posting
|
||||||
time: Date!
|
time: Time!
|
||||||
|
|
||||||
# The kind of post this is. Only "text", "scene" and "action" are RP, while others are annotations and 'commands'.
|
# The kind of post this is. Only "text", "scene" and "action" are RP, while others are annotations and 'commands'.
|
||||||
kind: String!
|
kind: String!
|
||||||
@@ -28,7 +28,7 @@ input PostAddInput {
|
|||||||
logId: String!
|
logId: String!
|
||||||
|
|
||||||
# The date and time of posting, in a RFC3339 format with up to a nanosecond's precision
|
# The date and time of posting, in a RFC3339 format with up to a nanosecond's precision
|
||||||
time: Date!
|
time: Time!
|
||||||
|
|
||||||
# The kind of post this is. Only "text", "scene" and "action" are RP, while others are annotations and 'commands'.
|
# The kind of post this is. Only "text", "scene" and "action" are RP, while others are annotations and 'commands'.
|
||||||
kind: String!
|
kind: String!
|
||||||
@@ -46,7 +46,7 @@ input PostEditInput {
|
|||||||
id: String!
|
id: String!
|
||||||
|
|
||||||
# The date and time of posting, in a RFC3339 format with up to a nanosecond's precision
|
# The date and time of posting, in a RFC3339 format with up to a nanosecond's precision
|
||||||
time: Date
|
time: Time
|
||||||
|
|
||||||
# The kind of post this is. Only "text", "scene" and "action" are RP, while others are annotations and 'commands'.
|
# The kind of post this is. Only "text", "scene" and "action" are RP, while others are annotations and 'commands'.
|
||||||
kind: String
|
kind: String
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ type Story {
|
|||||||
chapters: [Chapter!]!
|
chapters: [Chapter!]!
|
||||||
|
|
||||||
# The date the story was created.
|
# The date the story was created.
|
||||||
createdDate: Date!
|
createdDate: Time!
|
||||||
|
|
||||||
# The date the story is set in.
|
# The date the story is set in.
|
||||||
fictionalDate: Date
|
fictionalDate: Time
|
||||||
|
|
||||||
# The date of the last major update to the story. This being bumped means a new chapter has been added.
|
# The date of the last major update to the story. This being bumped means a new chapter has been added.
|
||||||
updatedDate: Date!
|
updatedDate: Time!
|
||||||
}
|
}
|
||||||
|
|
||||||
# Filter for stories query.
|
# Filter for stories query.
|
||||||
@@ -53,10 +53,10 @@ input StoriesFilter {
|
|||||||
open: Boolean
|
open: Boolean
|
||||||
|
|
||||||
# The earliest fictionalDate
|
# The earliest fictionalDate
|
||||||
earliestFictionalDate: Date
|
earliestFictionalDate: Time
|
||||||
|
|
||||||
# The latest fictionalDate
|
# The latest fictionalDate
|
||||||
latestFictionalDate: Date
|
latestFictionalDate: Time
|
||||||
|
|
||||||
# The max amount of stories to get (default: 30)
|
# The max amount of stories to get (default: 30)
|
||||||
limit: Int
|
limit: Int
|
||||||
@@ -85,7 +85,7 @@ input StoryAddInput {
|
|||||||
tags: [TagInput!]
|
tags: [TagInput!]
|
||||||
|
|
||||||
# Set the fictional date of the story.
|
# Set the fictional date of the story.
|
||||||
fictionalDate: Date
|
fictionalDate: Time
|
||||||
}
|
}
|
||||||
|
|
||||||
# Input for the editStory mutation
|
# Input for the editStory mutation
|
||||||
@@ -111,7 +111,7 @@ input StoryEditInput {
|
|||||||
listed: Boolean
|
listed: Boolean
|
||||||
|
|
||||||
# Set the fictional date of the story.
|
# Set the fictional date of the story.
|
||||||
fictionalDate: Date
|
fictionalDate: Time
|
||||||
|
|
||||||
# Clear the fictional date of the story.
|
# Clear the fictional date of the story.
|
||||||
clearFictionalDate: Boolean
|
clearFictionalDate: Boolean
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
package scalars
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/99designs/gqlgen/graphql"
|
|
||||||
)
|
|
||||||
|
|
||||||
// MarshalDate marshals time into gql Date type
|
|
||||||
func MarshalDate(t time.Time) graphql.Marshaler {
|
|
||||||
return graphql.WriterFunc(func(w io.Writer) {
|
|
||||||
w.Write([]byte(`"` + t.Format(time.RFC3339Nano) + `"`))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalDate unmarshals time from gql Date type
|
|
||||||
func UnmarshalDate(v interface{}) (time.Time, error) {
|
|
||||||
switch v := v.(type) {
|
|
||||||
case string:
|
|
||||||
return time.Parse(time.RFC3339Nano, v)
|
|
||||||
case int:
|
|
||||||
return time.Unix(0, int64(v)*1000000), nil
|
|
||||||
default:
|
|
||||||
return time.Time{}, fmt.Errorf("%T is not a valid time", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user