Browse Source

Fixed Change.object resolver not returning anything.

thegreatrefactor
Gisle Aune 6 years ago
parent
commit
c7c418aeab
  1. 3
      graph2/types/change.go
  2. 16
      models/change.go

3
graph2/types/change.go

@ -2,6 +2,7 @@ package types
import ( import (
"context" "context"
"log"
"git.aiterp.net/rpdata/api/graph2/input" "git.aiterp.net/rpdata/api/graph2/input"
"git.aiterp.net/rpdata/api/models" "git.aiterp.net/rpdata/api/models"
@ -16,6 +17,8 @@ func (r *changeResolver) Objects(ctx context.Context, obj *models.Change) ([]inp
for _, object := range objects { for _, object := range objects {
if changeObject, ok := object.(input.ChangeObject); ok { if changeObject, ok := object.(input.ChangeObject); ok {
results = append(results, changeObject) results = append(results, changeObject)
} else {
log.Printf("Type %T needs ChangeObject impl", object)
} }
} }

16
models/change.go

@ -33,28 +33,28 @@ func (change *Change) Objects() []interface{} {
data := make([]interface{}, 0, len(change.Logs)+len(change.Characters)+len(change.Channels)+len(change.Posts)+len(change.Stories)+len(change.Tags)+len(change.Chapters)+len(change.Comments)) data := make([]interface{}, 0, len(change.Logs)+len(change.Characters)+len(change.Channels)+len(change.Posts)+len(change.Stories)+len(change.Tags)+len(change.Chapters)+len(change.Comments))
for _, log := range change.Logs { for _, log := range change.Logs {
data = append(data, log)
data = append(data, &log)
} }
for _, channel := range change.Channels { for _, channel := range change.Channels {
data = append(data, channel)
data = append(data, &channel)
} }
for _, character := range change.Characters { for _, character := range change.Characters {
data = append(data, character)
data = append(data, &character)
} }
for _, post := range change.Posts { for _, post := range change.Posts {
data = append(data, post)
data = append(data, &post)
} }
for _, story := range change.Stories { for _, story := range change.Stories {
data = append(data, story)
data = append(data, &story)
} }
for _, tag := range change.Tags { for _, tag := range change.Tags {
data = append(data, tag)
data = append(data, &tag)
} }
for _, chapter := range change.Chapters { for _, chapter := range change.Chapters {
data = append(data, chapter)
data = append(data, &chapter)
} }
for _, comment := range change.Comments { for _, comment := range change.Comments {
data = append(data, comment)
data = append(data, &comment)
} }
return data return data

Loading…
Cancel
Save