mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 20:59:03 +00:00
25 lines
399 B
Go
25 lines
399 B
Go
package resolvers
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
//go:generate go run github.com/99designs/gqlgen
|
|
|
|
type Resolver struct {
|
|
database *gorm.DB
|
|
}
|
|
|
|
func NewRootResolver(db *gorm.DB) Resolver {
|
|
return Resolver{
|
|
database: db,
|
|
}
|
|
}
|
|
|
|
// DB returns a database instance that is tied to the given context
|
|
func (r *Resolver) DB(ctx context.Context) *gorm.DB {
|
|
return r.database.WithContext(ctx)
|
|
}
|