storj/pkg/satellite/satelliteweb/satelliteql/project.go
Bryan White 2a0c4e60d2
preparing for use of customtype gogo extension with NodeID type (#693)
* preparing for use of `customtype` gogo extension with `NodeID` type

* review changes

* preparing for use of `customtype` gogo extension with `NodeID` type

* review changes

* wip

* tests passing

* wip fixing tests

* more wip test fixing

* remove NodeIDList from proto files

* linter fixes

* linter fixes

* linter/review fixes

* more freaking linter fixes

* omg just kill me - linterrrrrrrr

* travis linter, i will muder you and your family in your sleep

* goimports everything - burn in hell travis

* goimports update

* go mod tidy
2018-11-29 19:39:27 +01:00

79 lines
2.0 KiB
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package satelliteql
import (
"github.com/graphql-go/graphql"
"storj.io/storj/pkg/satellite"
)
const (
projectType = "project"
projectInputType = "projectInput"
fieldOwnerName = "ownerName"
fieldDescription = "description"
// Indicates if user accepted Terms & Conditions during project creation
// Used in input model
fieldIsTermsAccepted = "isTermsAccepted"
)
// graphqlProject creates *graphql.Object type representation of satellite.ProjectInfo
func graphqlProject() *graphql.Object {
return graphql.NewObject(graphql.ObjectConfig{
Name: projectType,
Fields: graphql.Fields{
fieldID: &graphql.Field{
Type: graphql.String,
},
fieldOwnerName: &graphql.Field{
Type: graphql.String,
},
fieldName: &graphql.Field{
Type: graphql.String,
},
fieldDescription: &graphql.Field{
Type: graphql.String,
},
fieldIsTermsAccepted: &graphql.Field{
Type: graphql.Int,
},
fieldCreatedAt: &graphql.Field{
Type: graphql.DateTime,
},
},
})
}
// graphqlProjectInput creates graphql.InputObject type needed to create/update satellite.Project
func graphqlProjectInput() *graphql.InputObject {
return graphql.NewInputObject(graphql.InputObjectConfig{
Name: projectInputType,
Fields: graphql.InputObjectConfigFieldMap{
fieldID: &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
fieldName: &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
fieldDescription: &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
fieldIsTermsAccepted: &graphql.InputObjectFieldConfig{
Type: graphql.Boolean,
},
},
})
}
// fromMapProjectInfo creates satellite.ProjectInfo from input args
func fromMapProjectInfo(args map[string]interface{}) (project satellite.ProjectInfo) {
project.Name, _ = args[fieldName].(string)
project.Description, _ = args[fieldDescription].(string)
project.IsTermsAccepted, _ = args[fieldIsTermsAccepted].(bool)
return
}