fix: user profile not rendering in top navbar

This commit is contained in:
Jordan Knott
2021-10-30 17:20:41 -05:00
parent 800dd2014c
commit cea99397db
17 changed files with 280 additions and 160 deletions

View File

@ -2047,7 +2047,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Notified.Read(childComplexity), true
case "Notified.read_at":
case "Notified.readAt":
if e.complexity.Notified.ReadAt == nil {
break
}
@ -3185,7 +3185,7 @@ type Notified {
id: ID!
notification: Notification!
read: Boolean!
read_at: Time
readAt: Time
}
`, BuiltIn: false},
@ -12388,7 +12388,7 @@ func (ec *executionContext) _Notified_read(ctx context.Context, field graphql.Co
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
}
func (ec *executionContext) _Notified_read_at(ctx context.Context, field graphql.CollectedField, obj *Notified) (ret graphql.Marshaler) {
func (ec *executionContext) _Notified_readAt(ctx context.Context, field graphql.CollectedField, obj *Notified) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@ -21877,8 +21877,8 @@ func (ec *executionContext) _Notified(ctx context.Context, sel ast.SelectionSet,
if out.Values[i] == graphql.Null {
invalids++
}
case "read_at":
out.Values[i] = ec._Notified_read_at(ctx, field, obj)
case "readAt":
out.Values[i] = ec._Notified_readAt(ctx, field, obj)
default:
panic("unknown field " + strconv.Quote(field.Name))
}

View File

@ -371,7 +371,7 @@ type Notified struct {
ID uuid.UUID `json:"id"`
Notification *db.Notification `json:"notification"`
Read bool `json:"read"`
ReadAt *time.Time `json:"read_at"`
ReadAt *time.Time `json:"readAt"`
}
type OwnedList struct {

View File

@ -12,6 +12,7 @@ import (
"github.com/google/uuid"
"github.com/jordanknott/taskcafe/internal/db"
"github.com/jordanknott/taskcafe/internal/logger"
log "github.com/sirupsen/logrus"
)
func (r *notificationResolver) ID(ctx context.Context, obj *db.Notification) (uuid.UUID, error) {
@ -23,7 +24,23 @@ func (r *notificationResolver) ActionType(ctx context.Context, obj *db.Notificat
}
func (r *notificationResolver) CausedBy(ctx context.Context, obj *db.Notification) (*NotificationCausedBy, error) {
panic(fmt.Errorf("not implemented"))
user, err := r.Repository.GetUserAccountByID(ctx, obj.CausedBy)
if err != nil {
if err == sql.ErrNoRows {
return &NotificationCausedBy{
Fullname: "Unknown user",
Username: "unknown",
ID: obj.CausedBy,
}, nil
}
log.WithError(err).Error("error while resolving Notification.CausedBy")
return &NotificationCausedBy{}, err
}
return &NotificationCausedBy{
Fullname: user.FullName,
Username: user.Username,
ID: obj.CausedBy,
}, nil
}
func (r *notificationResolver) Data(ctx context.Context, obj *db.Notification) ([]NotificationData, error) {

View File

@ -33,6 +33,6 @@ type Notified {
id: ID!
notification: Notification!
read: Boolean!
read_at: Time
readAt: Time
}

View File

@ -33,5 +33,5 @@ type Notified {
id: ID!
notification: Notification!
read: Boolean!
read_at: Time
readAt: Time
}