2021-03-31 07:23:48 +02:00
|
|
|
package graph
|
|
|
|
|
|
|
|
import (
|
2024-07-16 12:08:10 +02:00
|
|
|
"sync"
|
|
|
|
|
2022-06-21 17:52:36 +02:00
|
|
|
"github.com/ClusterCockpit/cc-backend/internal/repository"
|
2024-07-16 12:08:10 +02:00
|
|
|
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
2021-03-31 07:23:48 +02:00
|
|
|
"github.com/jmoiron/sqlx"
|
|
|
|
)
|
|
|
|
|
2021-10-26 10:24:43 +02:00
|
|
|
// This file will not be regenerated automatically.
|
|
|
|
//
|
|
|
|
// It serves as dependency injection for your app, add any dependencies you require here.
|
2024-07-16 12:08:10 +02:00
|
|
|
var (
|
|
|
|
initOnce sync.Once
|
|
|
|
resolverInstance *Resolver
|
|
|
|
)
|
2021-05-03 10:23:47 +02:00
|
|
|
|
2021-03-31 07:23:48 +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
|
|
|
}
|
2024-07-16 12:08:10 +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
|
|
|
|
}
|