fix the bugs that were causing mutation response errors, and add duplicate subscription checks

MUTATIONS WORK BTW!!!
This commit is contained in:
2026-04-23 09:39:15 -05:00
parent 678ccdb1ba
commit c366164a9a
5 changed files with 50 additions and 8 deletions
+5 -2
View File
@@ -42,8 +42,11 @@ func main() {
}, []string{"messages"})
engine.RegisterMutation("createMessage", func(ctx *tether.MutationCtx) interface{} {
ctx.DB.Create(&Messages{ID: uuid.NewString(), Message: ctx.Params["message"].(string), SenderID: ctx.AuthCtx.UserID, RoomID: ctx.Params["room"].(string)})
return nil
msg := &Messages{ID: uuid.NewString(), Message: ctx.Params["message"].(string), SenderID: ctx.AuthCtx.UserID, RoomID: ctx.Params["room"].(string)}
if err := ctx.DB.Create(msg).Error; err != nil {
return map[string]interface{}{"error": err.Error()}
}
return msg
})
http.HandleFunc("/tether", engine.Handle)