cc-backend/internal/graph/resolver.go

40 lines
773 B
Go
Raw Permalink Normal View History

package graph
import (
"sync"
2022-06-21 17:52:36 +02:00
"github.com/ClusterCockpit/cc-backend/internal/repository"
"github.com/ClusterCockpit/cc-backend/pkg/log"
"github.com/jmoiron/sqlx"
)
// This file will not be regenerated automatically.
//
// It serves as dependency injection for your app, add any dependencies you require here.
var (
initOnce sync.Once
resolverInstance *Resolver
)
2021-05-03 10:23:47 +02:00
type Resolver struct {
2022-02-17 09:04:57 +01:00
DB *sqlx.DB
Repo *repository.JobRepository
2021-05-21 09:30:15 +02:00
}
func Init() {
initOnce.Do(func() {
db := repository.GetConnection()
resolverInstance = &Resolver{
DB: db.DB, Repo: repository.GetJobRepository(),
}
})
}
func GetResolverInstance() *Resolver {
if resolverInstance == nil {
log.Fatal("Authentication module not initialized!")
}
return resolverInstance
}