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-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
|
|
|
|
func CreateSchema(service *console.Service, mailService *mailservice.Service) (schema graphql.Schema, err error) {
|
|
|
|
storjql.WithLock(func() {
|
|
|
|
creator := TypeCreator{}
|
2019-02-05 19:44:00 +00:00
|
|
|
|
2019-03-05 10:38:21 +00:00
|
|
|
err = creator.Create(service, mailService)
|
|
|
|
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
|
|
|
}
|