Files
schemas/graph/resolver.go
T

37 lines
912 B
Go
Raw Normal View History

2022-10-09 15:23:52 +02:00
package graph
import (
2022-12-17 14:36:42 +01:00
"context"
2023-04-27 07:09:10 +02:00
"fmt"
2022-12-17 14:36:42 +01:00
2022-10-09 15:23:52 +02:00
"github.com/apex/log"
"gitlab.com/unboundsoftware/eventsourced/eventsourced"
"gitlab.com/unboundsoftware/schemas/cache"
)
//go:generate go run github.com/99designs/gqlgen
// This file will not be regenerated automatically.
//
// It serves as dependency injection for your app, add any dependencies you require here.
type Publisher interface {
2022-12-17 14:36:42 +01:00
Publish(ctx context.Context, event eventsourced.Event) error
2022-10-09 15:23:52 +02:00
}
type Resolver struct {
EventStore eventsourced.EventStore
Publisher Publisher
Logger log.Interface
Cache *cache.Cache
}
2022-12-17 14:36:42 +01:00
func (r *Resolver) handler(ctx context.Context, aggregate eventsourced.Aggregate) (eventsourced.CommandHandler, error) {
return eventsourced.NewHandler(ctx, aggregate, r.EventStore, eventsourced.WithEventPublisher(r.Publisher))
2022-10-09 15:23:52 +02:00
}
2023-04-27 07:09:10 +02:00
func apiKeyId(orgId, name string) string {
return fmt.Sprintf("%s-%s", orgId, name)
}