2019-03-05 10:38:21 +00:00
|
|
|
// Copyright (C) 2018 Storj Labs, Inc.
|
2019-02-05 19:44:00 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package consoleql
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/graphql-go/graphql"
|
2019-03-26 15:56:16 +00:00
|
|
|
"go.uber.org/zap"
|
2019-02-05 19:44:00 +00:00
|
|
|
|
2019-03-05 10:38:21 +00:00
|
|
|
"storj.io/storj/internal/storjql"
|
2019-02-05 19:44:00 +00:00
|
|
|
"storj.io/storj/satellite/console"
|
2019-03-02 15:22:20 +00:00
|
|
|
"storj.io/storj/satellite/mailservice"
|
2019-02-05 19:44:00 +00:00
|
|
|
)
|
|
|
|
|
2019-03-05 10:38:21 +00:00
|
|
|
// CreateSchema creates a schema for satellites console graphql api
|
2019-03-26 15:56:16 +00:00
|
|
|
func CreateSchema(log *zap.Logger, service *console.Service, mailService *mailservice.Service) (schema graphql.Schema, err error) {
|
2019-03-05 10:38:21 +00:00
|
|
|
storjql.WithLock(func() {
|
|
|
|
creator := TypeCreator{}
|
2019-02-05 19:44:00 +00:00
|
|
|
|
2019-03-26 15:56:16 +00:00
|
|
|
err = creator.Create(log, service, mailService)
|
2019-03-05 10:38:21 +00:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
2019-02-05 19:44:00 +00:00
|
|
|
|
2019-03-05 10:38:21 +00:00
|
|
|
schema, err = graphql.NewSchema(graphql.SchemaConfig{
|
|
|
|
Query: creator.RootQuery(),
|
|
|
|
Mutation: creator.RootMutation(),
|
|
|
|
})
|
2019-02-05 19:44:00 +00:00
|
|
|
})
|
2019-03-05 10:38:21 +00:00
|
|
|
|
|
|
|
return schema, err
|
2019-02-05 19:44:00 +00:00
|
|
|
}
|