Browse Source

graph2: Changed Comment to return null instead of a zero-date if it's cleared.

module-madness-pointers
Gisle Aune 6 years ago
parent
commit
dfa9fb4025
  1. 3
      graph2/gqlgen.yml
  2. 9
      graph2/types/comment.go

3
graph2/gqlgen.yml

@ -37,6 +37,9 @@ 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:

9
graph2/types/comment.go

@ -3,6 +3,7 @@ package types
import ( import (
"context" "context"
"errors" "errors"
"time"
"git.aiterp.net/rpdata/api/internal/loader" "git.aiterp.net/rpdata/api/internal/loader"
"git.aiterp.net/rpdata/api/models" "git.aiterp.net/rpdata/api/models"
@ -28,5 +29,13 @@ func (r *commentResolver) Character(ctx context.Context, obj *models.Comment) (*
return &character, nil return &character, nil
} }
func (r *commentResolver) FictionalDate(ctx context.Context, obj *models.Comment) (*time.Time, error) {
if obj.FictionalDate.IsZero() {
return nil, nil
}
return &obj.FictionalDate, nil
}
// CommentResolver is a resolver // CommentResolver is a resolver
var CommentResolver commentResolver var CommentResolver commentResolver
Loading…
Cancel
Save