1// Copyright (C) 2019 Storj Labs, Inc. 2// See LICENSE for copying information. 3 4package consoleql 5 6import ( 7 "github.com/graphql-go/graphql" 8) 9 10const ( 11 // UserType is a graphql type for user. 12 UserType = "user" 13 // UserInputType is a graphql type for user input. 14 UserInputType = "userInput" 15 // FieldID is a field name for id. 16 FieldID = "id" 17 // FieldEmail is a field name for email. 18 FieldEmail = "email" 19 // FieldPassword is a field name for password. 20 FieldPassword = "password" 21 // FieldFullName is a field name for "first name". 22 FieldFullName = "fullName" 23 // FieldShortName is a field name for "last name". 24 FieldShortName = "shortName" 25 // FieldCreatedAt is a field name for created at timestamp. 26 FieldCreatedAt = "createdAt" 27 // FieldPartnerID is a field name for partnerID. 28 FieldPartnerID = "partnerId" 29) 30 31// base graphql config for user. 32func baseUserConfig() graphql.ObjectConfig { 33 return graphql.ObjectConfig{ 34 Name: UserType, 35 Fields: graphql.Fields{ 36 FieldID: &graphql.Field{ 37 Type: graphql.String, 38 }, 39 FieldEmail: &graphql.Field{ 40 Type: graphql.String, 41 }, 42 FieldFullName: &graphql.Field{ 43 Type: graphql.String, 44 }, 45 FieldShortName: &graphql.Field{ 46 Type: graphql.String, 47 }, 48 FieldCreatedAt: &graphql.Field{ 49 Type: graphql.DateTime, 50 }, 51 FieldPartnerID: &graphql.Field{ 52 Type: graphql.String, 53 }, 54 }, 55 } 56} 57 58// graphqlUser creates *graphql.Object type representation of satellite.User. 59func graphqlUser() *graphql.Object { 60 // TODO: simplify 61 return graphql.NewObject(baseUserConfig()) 62} 63 64// graphqlUserInput creates graphql.InputObject type needed to register/update satellite.User. 65func graphqlUserInput() *graphql.InputObject { 66 return graphql.NewInputObject(graphql.InputObjectConfig{ 67 Name: UserInputType, 68 Fields: graphql.InputObjectConfigFieldMap{ 69 FieldEmail: &graphql.InputObjectFieldConfig{ 70 Type: graphql.String, 71 }, 72 FieldFullName: &graphql.InputObjectFieldConfig{ 73 Type: graphql.String, 74 }, 75 FieldShortName: &graphql.InputObjectFieldConfig{ 76 Type: graphql.String, 77 }, 78 FieldPassword: &graphql.InputObjectFieldConfig{ 79 Type: graphql.String, 80 }, 81 FieldPartnerID: &graphql.InputObjectFieldConfig{ 82 Type: graphql.String, 83 }, 84 }, 85 }) 86} 87