From 1d3e911515fe66e0df7d027e52a94dc3b831ac64 Mon Sep 17 00:00:00 2001 From: wisplite Date: Thu, 26 Feb 2026 15:11:47 -0600 Subject: [PATCH] added some stuff --- context.go | 18 ++++++++++++++++++ engine.go | 10 ++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 context.go diff --git a/context.go b/context.go new file mode 100644 index 0000000..04ef191 --- /dev/null +++ b/context.go @@ -0,0 +1,18 @@ +package tether + +import "gorm.io/gorm" + +type AuthCtx struct { + UserID string + IsLoggedIn bool +} + +type QueryCtx struct { + DB *gorm.DB + AuthCtx *AuthCtx +} + +type MutationCtx struct { + DB *gorm.DB + AuthCtx *AuthCtx +} diff --git a/engine.go b/engine.go index 4100c4b..f21853e 100644 --- a/engine.go +++ b/engine.go @@ -6,10 +6,16 @@ import ( ) type Engine struct { - db *gorm.DB - channels map[string]*reactivity.Channel + db *gorm.DB + channels map[string]*reactivity.Channel + mutations []func(ctx *MutationCtx) error + queries []func(ctx *QueryCtx) error } func NewEngine(db *gorm.DB) *Engine { return &Engine{db: db, channels: make(map[string]*reactivity.Channel)} } + +func (e *Engine) RegisterMutation(mutation func(ctx *MutationCtx) error) { + e.mutations = append(e.mutations, mutation) +}