mutation proof of concept

client can now send mutations and server properly executes them
TODO: implement query execution, add auth, add storage
This commit is contained in:
2026-04-21 23:07:55 -05:00
parent c834c11bc8
commit 8092488b29
8 changed files with 112 additions and 26 deletions
+11 -5
View File
@@ -6,6 +6,7 @@ import (
"net/http"
"github.com/glebarez/sqlite"
"github.com/google/uuid"
"github.com/wisplite/tether"
"gorm.io/gorm"
)
@@ -16,11 +17,11 @@ type User struct {
}
type Messages struct {
ID string `gorm:"primaryKey"`
Message string
SenderID string
ReceiverID string
CreatedAt time.Time
ID string `gorm:"primaryKey"`
Message string
SenderID string
RoomID string
CreatedAt time.Time
}
func main() {
@@ -42,6 +43,11 @@ func main() {
return nil
})
engine.RegisterMutation("createMessage", func(ctx *tether.MutationCtx) error {
ctx.DB.Create(&Messages{ID: uuid.NewString(), Message: ctx.Params["message"].(string), SenderID: ctx.AuthCtx.UserID, RoomID: ctx.Params["room"].(string)})
return nil
})
http.HandleFunc("/tether", engine.Handle)
http.ListenAndServe(":8080", nil)
}