feature: various additions

This commit is contained in:
Jordan Knott
2020-06-12 17:21:58 -05:00
parent 4c02df9061
commit 6267a37b6e
72 changed files with 2038 additions and 389 deletions

View File

@ -74,6 +74,7 @@ type ComplexityRoot struct {
Mutation struct {
AddTaskLabel func(childComplexity int, input *AddTaskLabelInput) int
AssignTask func(childComplexity int, input *AssignTaskInput) int
ClearProfileAvatar func(childComplexity int) int
CreateProject func(childComplexity int, input NewProject) int
CreateProjectLabel func(childComplexity int, input NewProjectLabel) int
CreateRefreshToken func(childComplexity int, input NewRefreshToken) int
@ -94,6 +95,7 @@ type ComplexityRoot struct {
UpdateProjectName func(childComplexity int, input *UpdateProjectName) int
UpdateTaskDescription func(childComplexity int, input UpdateTaskDescriptionInput) int
UpdateTaskGroupLocation func(childComplexity int, input NewTaskGroupLocation) int
UpdateTaskGroupName func(childComplexity int, input UpdateTaskGroupName) int
UpdateTaskLocation func(childComplexity int, input NewTaskLocation) int
UpdateTaskName func(childComplexity int, input UpdateTaskName) int
}
@ -123,9 +125,8 @@ type ComplexityRoot struct {
}
ProjectMember struct {
FirstName func(childComplexity int) int
FullName func(childComplexity int) int
ID func(childComplexity int) int
LastName func(childComplexity int) int
ProfileIcon func(childComplexity int) int
}
@ -193,9 +194,9 @@ type ComplexityRoot struct {
UserAccount struct {
CreatedAt func(childComplexity int) int
Email func(childComplexity int) int
FirstName func(childComplexity int) int
FullName func(childComplexity int) int
ID func(childComplexity int) int
LastName func(childComplexity int) int
Initials func(childComplexity int) int
ProfileIcon func(childComplexity int) int
Username func(childComplexity int) int
}
@ -208,6 +209,7 @@ type MutationResolver interface {
CreateRefreshToken(ctx context.Context, input NewRefreshToken) (*pg.RefreshToken, error)
CreateUserAccount(ctx context.Context, input NewUserAccount) (*pg.UserAccount, error)
CreateTeam(ctx context.Context, input NewTeam) (*pg.Team, error)
ClearProfileAvatar(ctx context.Context) (*pg.UserAccount, error)
CreateProject(ctx context.Context, input NewProject) (*pg.Project, error)
UpdateProjectName(ctx context.Context, input *UpdateProjectName) (*pg.Project, error)
CreateProjectLabel(ctx context.Context, input NewProjectLabel) (*pg.ProjectLabel, error)
@ -217,6 +219,7 @@ type MutationResolver interface {
UpdateProjectLabelColor(ctx context.Context, input UpdateProjectLabelColor) (*pg.ProjectLabel, error)
CreateTaskGroup(ctx context.Context, input NewTaskGroup) (*pg.TaskGroup, error)
UpdateTaskGroupLocation(ctx context.Context, input NewTaskGroupLocation) (*pg.TaskGroup, error)
UpdateTaskGroupName(ctx context.Context, input UpdateTaskGroupName) (*pg.TaskGroup, error)
DeleteTaskGroup(ctx context.Context, input DeleteTaskGroupInput) (*DeleteTaskGroupPayload, error)
AddTaskLabel(ctx context.Context, input *AddTaskLabelInput) (*pg.Task, error)
RemoveTaskLabel(ctx context.Context, input *RemoveTaskLabelInput) (*pg.Task, error)
@ -381,6 +384,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Mutation.AssignTask(childComplexity, args["input"].(*AssignTaskInput)), true
case "Mutation.clearProfileAvatar":
if e.complexity.Mutation.ClearProfileAvatar == nil {
break
}
return e.complexity.Mutation.ClearProfileAvatar(childComplexity), true
case "Mutation.createProject":
if e.complexity.Mutation.CreateProject == nil {
break
@ -621,6 +631,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Mutation.UpdateTaskGroupLocation(childComplexity, args["input"].(NewTaskGroupLocation)), true
case "Mutation.updateTaskGroupName":
if e.complexity.Mutation.UpdateTaskGroupName == nil {
break
}
args, err := ec.field_Mutation_updateTaskGroupName_args(context.TODO(), rawArgs)
if err != nil {
return 0, false
}
return e.complexity.Mutation.UpdateTaskGroupName(childComplexity, args["input"].(UpdateTaskGroupName)), true
case "Mutation.updateTaskLocation":
if e.complexity.Mutation.UpdateTaskLocation == nil {
break
@ -750,12 +772,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.ProjectLabel.Name(childComplexity), true
case "ProjectMember.firstName":
if e.complexity.ProjectMember.FirstName == nil {
case "ProjectMember.fullName":
if e.complexity.ProjectMember.FullName == nil {
break
}
return e.complexity.ProjectMember.FirstName(childComplexity), true
return e.complexity.ProjectMember.FullName(childComplexity), true
case "ProjectMember.id":
if e.complexity.ProjectMember.ID == nil {
@ -764,13 +786,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.ProjectMember.ID(childComplexity), true
case "ProjectMember.lastName":
if e.complexity.ProjectMember.LastName == nil {
break
}
return e.complexity.ProjectMember.LastName(childComplexity), true
case "ProjectMember.profileIcon":
if e.complexity.ProjectMember.ProfileIcon == nil {
break
@ -1071,12 +1086,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.UserAccount.Email(childComplexity), true
case "UserAccount.firstName":
if e.complexity.UserAccount.FirstName == nil {
case "UserAccount.fullName":
if e.complexity.UserAccount.FullName == nil {
break
}
return e.complexity.UserAccount.FirstName(childComplexity), true
return e.complexity.UserAccount.FullName(childComplexity), true
case "UserAccount.id":
if e.complexity.UserAccount.ID == nil {
@ -1085,12 +1100,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.UserAccount.ID(childComplexity), true
case "UserAccount.lastName":
if e.complexity.UserAccount.LastName == nil {
case "UserAccount.initials":
if e.complexity.UserAccount.Initials == nil {
break
}
return e.complexity.UserAccount.LastName(childComplexity), true
return e.complexity.UserAccount.Initials(childComplexity), true
case "UserAccount.profileIcon":
if e.complexity.UserAccount.ProfileIcon == nil {
@ -1172,6 +1187,7 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er
var sources = []*ast.Source{
&ast.Source{Name: "graph/schema.graphqls", Input: `scalar Time
scalar UUID
scalar Upload
type ProjectLabel {
id: ID!
@ -1201,8 +1217,7 @@ type ProfileIcon {
type ProjectMember {
id: ID!
firstName: String!
lastName: String!
fullName: String!
profileIcon: ProfileIcon!
}
@ -1217,8 +1232,8 @@ type UserAccount {
id: ID!
email: String!
createdAt: Time!
firstName: String!
lastName: String!
fullName: String!
initials: String!
username: String!
profileIcon: ProfileIcon!
}
@ -1295,8 +1310,8 @@ input NewRefreshToken {
input NewUserAccount {
username: String!
email: String!
firstName: String!
lastName: String!
fullName: String!
initials: String!
password: String!
}
@ -1427,12 +1442,19 @@ type UpdateTaskLocationPayload {
previousTaskGroupID: UUID!
task: Task!
}
input UpdateTaskGroupName {
taskGroupID: UUID!
name: String!
}
type Mutation {
createRefreshToken(input: NewRefreshToken!): RefreshToken!
createUserAccount(input: NewUserAccount!): UserAccount!
createTeam(input: NewTeam!): Team!
clearProfileAvatar: UserAccount!
createProject(input: NewProject!): Project!
updateProjectName(input: UpdateProjectName): Project!
@ -1445,6 +1467,7 @@ type Mutation {
createTaskGroup(input: NewTaskGroup!): TaskGroup!
updateTaskGroupLocation(input: NewTaskGroupLocation!): TaskGroup!
updateTaskGroupName(input: UpdateTaskGroupName!): TaskGroup!
deleteTaskGroup(input: DeleteTaskGroupInput!): DeleteTaskGroupPayload!
addTaskLabel(input: AddTaskLabelInput): Task!
@ -1777,6 +1800,20 @@ func (ec *executionContext) field_Mutation_updateTaskGroupLocation_args(ctx cont
return args, nil
}
func (ec *executionContext) field_Mutation_updateTaskGroupName_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 UpdateTaskGroupName
if tmp, ok := rawArgs["input"]; ok {
arg0, err = ec.unmarshalNUpdateTaskGroupName2githubᚗcomᚋjordanknottᚋprojectᚑcitadelᚋapiᚋgraphᚐUpdateTaskGroupName(ctx, tmp)
if err != nil {
return nil, err
}
}
args["input"] = arg0
return args, nil
}
func (ec *executionContext) field_Mutation_updateTaskLocation_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
@ -2306,6 +2343,40 @@ func (ec *executionContext) _Mutation_createTeam(ctx context.Context, field grap
return ec.marshalNTeam2ᚖgithubᚗcomᚋjordanknottᚋprojectᚑcitadelᚋapiᚋpgᚐTeam(ctx, field.Selections, res)
}
func (ec *executionContext) _Mutation_clearProfileAvatar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Mutation",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.Mutation().ClearProfileAvatar(rctx)
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(*pg.UserAccount)
fc.Result = res
return ec.marshalNUserAccount2ᚖgithubᚗcomᚋjordanknottᚋprojectᚑcitadelᚋapiᚋpgᚐUserAccount(ctx, field.Selections, res)
}
func (ec *executionContext) _Mutation_createProject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@ -2675,6 +2746,47 @@ func (ec *executionContext) _Mutation_updateTaskGroupLocation(ctx context.Contex
return ec.marshalNTaskGroup2ᚖgithubᚗcomᚋjordanknottᚋprojectᚑcitadelᚋapiᚋpgᚐTaskGroup(ctx, field.Selections, res)
}
func (ec *executionContext) _Mutation_updateTaskGroupName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "Mutation",
Field: field,
Args: nil,
IsMethod: true,
}
ctx = graphql.WithFieldContext(ctx, fc)
rawArgs := field.ArgumentMap(ec.Variables)
args, err := ec.field_Mutation_updateTaskGroupName_args(ctx, rawArgs)
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
fc.Args = args
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.Mutation().UpdateTaskGroupName(rctx, args["input"].(UpdateTaskGroupName))
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(*pg.TaskGroup)
fc.Result = res
return ec.marshalNTaskGroup2ᚖgithubᚗcomᚋjordanknottᚋprojectᚑcitadelᚋapiᚋpgᚐTaskGroup(ctx, field.Selections, res)
}
func (ec *executionContext) _Mutation_deleteTaskGroup(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@ -3699,7 +3811,7 @@ func (ec *executionContext) _ProjectMember_id(ctx context.Context, field graphql
return ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res)
}
func (ec *executionContext) _ProjectMember_firstName(ctx context.Context, field graphql.CollectedField, obj *ProjectMember) (ret graphql.Marshaler) {
func (ec *executionContext) _ProjectMember_fullName(ctx context.Context, field graphql.CollectedField, obj *ProjectMember) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@ -3716,41 +3828,7 @@ func (ec *executionContext) _ProjectMember_firstName(ctx context.Context, field
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.FirstName, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(string)
fc.Result = res
return ec.marshalNString2string(ctx, field.Selections, res)
}
func (ec *executionContext) _ProjectMember_lastName(ctx context.Context, field graphql.CollectedField, obj *ProjectMember) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "ProjectMember",
Field: field,
Args: nil,
IsMethod: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.LastName, nil
return obj.FullName, nil
})
if err != nil {
ec.Error(ctx, err)
@ -5255,7 +5333,7 @@ func (ec *executionContext) _UserAccount_createdAt(ctx context.Context, field gr
return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res)
}
func (ec *executionContext) _UserAccount_firstName(ctx context.Context, field graphql.CollectedField, obj *pg.UserAccount) (ret graphql.Marshaler) {
func (ec *executionContext) _UserAccount_fullName(ctx context.Context, field graphql.CollectedField, obj *pg.UserAccount) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@ -5272,7 +5350,7 @@ func (ec *executionContext) _UserAccount_firstName(ctx context.Context, field gr
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.FirstName, nil
return obj.FullName, nil
})
if err != nil {
ec.Error(ctx, err)
@ -5289,7 +5367,7 @@ func (ec *executionContext) _UserAccount_firstName(ctx context.Context, field gr
return ec.marshalNString2string(ctx, field.Selections, res)
}
func (ec *executionContext) _UserAccount_lastName(ctx context.Context, field graphql.CollectedField, obj *pg.UserAccount) (ret graphql.Marshaler) {
func (ec *executionContext) _UserAccount_initials(ctx context.Context, field graphql.CollectedField, obj *pg.UserAccount) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@ -5306,7 +5384,7 @@ func (ec *executionContext) _UserAccount_lastName(ctx context.Context, field gra
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.LastName, nil
return obj.Initials, nil
})
if err != nil {
ec.Error(ctx, err)
@ -6854,15 +6932,15 @@ func (ec *executionContext) unmarshalInputNewUserAccount(ctx context.Context, ob
if err != nil {
return it, err
}
case "firstName":
case "fullName":
var err error
it.FirstName, err = ec.unmarshalNString2string(ctx, v)
it.FullName, err = ec.unmarshalNString2string(ctx, v)
if err != nil {
return it, err
}
case "lastName":
case "initials":
var err error
it.LastName, err = ec.unmarshalNString2string(ctx, v)
it.Initials, err = ec.unmarshalNString2string(ctx, v)
if err != nil {
return it, err
}
@ -7088,6 +7166,30 @@ func (ec *executionContext) unmarshalInputUpdateTaskDescriptionInput(ctx context
return it, nil
}
func (ec *executionContext) unmarshalInputUpdateTaskGroupName(ctx context.Context, obj interface{}) (UpdateTaskGroupName, error) {
var it UpdateTaskGroupName
var asMap = obj.(map[string]interface{})
for k, v := range asMap {
switch k {
case "taskGroupID":
var err error
it.TaskGroupID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v)
if err != nil {
return it, err
}
case "name":
var err error
it.Name, err = ec.unmarshalNString2string(ctx, v)
if err != nil {
return it, err
}
}
}
return it, nil
}
func (ec *executionContext) unmarshalInputUpdateTaskName(ctx context.Context, obj interface{}) (UpdateTaskName, error) {
var it UpdateTaskName
var asMap = obj.(map[string]interface{})
@ -7265,6 +7367,11 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)
if out.Values[i] == graphql.Null {
invalids++
}
case "clearProfileAvatar":
out.Values[i] = ec._Mutation_clearProfileAvatar(ctx, field)
if out.Values[i] == graphql.Null {
invalids++
}
case "createProject":
out.Values[i] = ec._Mutation_createProject(ctx, field)
if out.Values[i] == graphql.Null {
@ -7310,6 +7417,11 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)
if out.Values[i] == graphql.Null {
invalids++
}
case "updateTaskGroupName":
out.Values[i] = ec._Mutation_updateTaskGroupName(ctx, field)
if out.Values[i] == graphql.Null {
invalids++
}
case "deleteTaskGroup":
out.Values[i] = ec._Mutation_deleteTaskGroup(ctx, field)
if out.Values[i] == graphql.Null {
@ -7607,13 +7719,8 @@ func (ec *executionContext) _ProjectMember(ctx context.Context, sel ast.Selectio
if out.Values[i] == graphql.Null {
invalids++
}
case "firstName":
out.Values[i] = ec._ProjectMember_firstName(ctx, field, obj)
if out.Values[i] == graphql.Null {
invalids++
}
case "lastName":
out.Values[i] = ec._ProjectMember_lastName(ctx, field, obj)
case "fullName":
out.Values[i] = ec._ProjectMember_fullName(ctx, field, obj)
if out.Values[i] == graphql.Null {
invalids++
}
@ -8223,13 +8330,13 @@ func (ec *executionContext) _UserAccount(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "firstName":
out.Values[i] = ec._UserAccount_firstName(ctx, field, obj)
case "fullName":
out.Values[i] = ec._UserAccount_fullName(ctx, field, obj)
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
case "lastName":
out.Values[i] = ec._UserAccount_lastName(ctx, field, obj)
case "initials":
out.Values[i] = ec._UserAccount_initials(ctx, field, obj)
if out.Values[i] == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
@ -9158,6 +9265,10 @@ func (ec *executionContext) unmarshalNUpdateTaskDescriptionInput2githubᚗcomᚋ
return ec.unmarshalInputUpdateTaskDescriptionInput(ctx, v)
}
func (ec *executionContext) unmarshalNUpdateTaskGroupName2githubᚗcomᚋjordanknottᚋprojectᚑcitadelᚋapiᚋgraphᚐUpdateTaskGroupName(ctx context.Context, v interface{}) (UpdateTaskGroupName, error) {
return ec.unmarshalInputUpdateTaskGroupName(ctx, v)
}
func (ec *executionContext) marshalNUpdateTaskLocationPayload2githubᚗcomᚋjordanknottᚋprojectᚑcitadelᚋapiᚋgraphᚐUpdateTaskLocationPayload(ctx context.Context, sel ast.SelectionSet, v UpdateTaskLocationPayload) graphql.Marshaler {
return ec._UpdateTaskLocationPayload(ctx, sel, &v)
}

View File

@ -100,11 +100,11 @@ type NewTeam struct {
}
type NewUserAccount struct {
Username string `json:"username"`
Email string `json:"email"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Password string `json:"password"`
Username string `json:"username"`
Email string `json:"email"`
FullName string `json:"fullName"`
Initials string `json:"initials"`
Password string `json:"password"`
}
type ProfileIcon struct {
@ -115,8 +115,7 @@ type ProfileIcon struct {
type ProjectMember struct {
ID uuid.UUID `json:"id"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
FullName string `json:"fullName"`
ProfileIcon *ProfileIcon `json:"profileIcon"`
}
@ -169,6 +168,11 @@ type UpdateTaskDescriptionInput struct {
Description string `json:"description"`
}
type UpdateTaskGroupName struct {
TaskGroupID uuid.UUID `json:"taskGroupID"`
Name string `json:"name"`
}
type UpdateTaskLocationPayload struct {
PreviousTaskGroupID uuid.UUID `json:"previousTaskGroupID"`
Task *pg.Task `json:"task"`

View File

@ -1,5 +1,6 @@
scalar Time
scalar UUID
scalar Upload
type ProjectLabel {
id: ID!
@ -29,8 +30,7 @@ type ProfileIcon {
type ProjectMember {
id: ID!
firstName: String!
lastName: String!
fullName: String!
profileIcon: ProfileIcon!
}
@ -45,8 +45,8 @@ type UserAccount {
id: ID!
email: String!
createdAt: Time!
firstName: String!
lastName: String!
fullName: String!
initials: String!
username: String!
profileIcon: ProfileIcon!
}
@ -123,8 +123,8 @@ input NewRefreshToken {
input NewUserAccount {
username: String!
email: String!
firstName: String!
lastName: String!
fullName: String!
initials: String!
password: String!
}
@ -255,12 +255,19 @@ type UpdateTaskLocationPayload {
previousTaskGroupID: UUID!
task: Task!
}
input UpdateTaskGroupName {
taskGroupID: UUID!
name: String!
}
type Mutation {
createRefreshToken(input: NewRefreshToken!): RefreshToken!
createUserAccount(input: NewUserAccount!): UserAccount!
createTeam(input: NewTeam!): Team!
clearProfileAvatar: UserAccount!
createProject(input: NewProject!): Project!
updateProjectName(input: UpdateProjectName): Project!
@ -273,6 +280,7 @@ type Mutation {
createTaskGroup(input: NewTaskGroup!): TaskGroup!
updateTaskGroupLocation(input: NewTaskGroupLocation!): TaskGroup!
updateTaskGroupName(input: UpdateTaskGroupName!): TaskGroup!
deleteTaskGroup(input: DeleteTaskGroupInput!): DeleteTaskGroupPayload!
addTaskLabel(input: AddTaskLabelInput): Task!

View File

@ -29,7 +29,14 @@ func (r *mutationResolver) CreateRefreshToken(ctx context.Context, input NewRefr
func (r *mutationResolver) CreateUserAccount(ctx context.Context, input NewUserAccount) (*pg.UserAccount, error) {
createdAt := time.Now().UTC()
userAccount, err := r.Repository.CreateUserAccount(ctx, pg.CreateUserAccountParams{input.FirstName, input.LastName, input.Email, input.Username, createdAt, input.Password})
userAccount, err := r.Repository.CreateUserAccount(ctx, pg.CreateUserAccountParams{
FullName: input.FullName,
Initials: input.Initials,
Email: input.Email,
Username: input.Username,
CreatedAt: createdAt,
PasswordHash: input.Password,
})
return &userAccount, err
}
@ -43,6 +50,21 @@ func (r *mutationResolver) CreateTeam(ctx context.Context, input NewTeam) (*pg.T
return &team, err
}
func (r *mutationResolver) ClearProfileAvatar(ctx context.Context) (*pg.UserAccount, error) {
userID, ok := GetUserID(ctx)
if !ok {
return &pg.UserAccount{}, fmt.Errorf("internal server error")
}
log.WithFields(log.Fields{
"userID": userID,
}).Info("getting user account")
user, err := r.Repository.UpdateUserAccountProfileAvatarURL(ctx, pg.UpdateUserAccountProfileAvatarURLParams{UserID: userID, ProfileAvatarUrl: sql.NullString{Valid: false, String: ""}})
if err != nil {
return &pg.UserAccount{}, err
}
return &user, nil
}
func (r *mutationResolver) CreateProject(ctx context.Context, input NewProject) (*pg.Project, error) {
createdAt := time.Now().UTC()
project, err := r.Repository.CreateProject(ctx, pg.CreateProjectParams{input.UserID, input.TeamID, createdAt, input.Name})
@ -120,6 +142,10 @@ func (r *mutationResolver) UpdateTaskGroupLocation(ctx context.Context, input Ne
return &taskGroup, err
}
func (r *mutationResolver) UpdateTaskGroupName(ctx context.Context, input UpdateTaskGroupName) (*pg.TaskGroup, error) {
panic(fmt.Errorf("not implemented"))
}
func (r *mutationResolver) DeleteTaskGroup(ctx context.Context, input DeleteTaskGroupInput) (*DeleteTaskGroupPayload, error) {
deletedTasks, err := r.Repository.DeleteTasksByTaskGroupID(ctx, input.TaskGroupID)
if err != nil {
@ -301,9 +327,12 @@ func (r *projectResolver) Owner(ctx context.Context, obj *pg.Project) (*ProjectM
if err != nil {
return &ProjectMember{}, err
}
initials := string([]rune(user.FirstName)[0]) + string([]rune(user.LastName)[0])
profileIcon := &ProfileIcon{nil, &initials, &user.ProfileBgColor}
return &ProjectMember{obj.Owner, user.FirstName, user.LastName, profileIcon}, nil
var url *string
if user.ProfileAvatarUrl.Valid {
url = &user.ProfileAvatarUrl.String
}
profileIcon := &ProfileIcon{url, &user.Initials, &user.ProfileBgColor}
return &ProjectMember{obj.Owner, user.FullName, profileIcon}, nil
}
func (r *projectResolver) TaskGroups(ctx context.Context, obj *pg.Project) ([]pg.TaskGroup, error) {
@ -316,9 +345,12 @@ func (r *projectResolver) Members(ctx context.Context, obj *pg.Project) ([]Proje
if err != nil {
return members, err
}
initials := string([]rune(user.FirstName)[0]) + string([]rune(user.LastName)[0])
profileIcon := &ProfileIcon{nil, &initials, &user.ProfileBgColor}
members = append(members, ProjectMember{obj.Owner, user.FirstName, user.LastName, profileIcon})
var url *string
if user.ProfileAvatarUrl.Valid {
url = &user.ProfileAvatarUrl.String
}
profileIcon := &ProfileIcon{url, &user.Initials, &user.ProfileBgColor}
members = append(members, ProjectMember{obj.Owner, user.FullName, profileIcon})
return members, nil
}
@ -463,9 +495,12 @@ func (r *taskResolver) Assigned(ctx context.Context, obj *pg.Task) ([]ProjectMem
if err != nil {
return taskMembers, err
}
initials := string([]rune(user.FirstName)[0]) + string([]rune(user.LastName)[0])
profileIcon := &ProfileIcon{nil, &initials, &user.ProfileBgColor}
taskMembers = append(taskMembers, ProjectMember{taskMemberLink.UserID, user.FirstName, user.LastName, profileIcon})
var url *string
if user.ProfileAvatarUrl.Valid {
url = &user.ProfileAvatarUrl.String
}
profileIcon := &ProfileIcon{url, &user.Initials, &user.ProfileBgColor}
taskMembers = append(taskMembers, ProjectMember{taskMemberLink.UserID, user.FullName, profileIcon})
}
return taskMembers, nil
}
@ -505,8 +540,11 @@ func (r *userAccountResolver) ID(ctx context.Context, obj *pg.UserAccount) (uuid
}
func (r *userAccountResolver) ProfileIcon(ctx context.Context, obj *pg.UserAccount) (*ProfileIcon, error) {
initials := string([]rune(obj.FirstName)[0]) + string([]rune(obj.LastName)[0])
profileIcon := &ProfileIcon{nil, &initials, &obj.ProfileBgColor}
var url *string
if obj.ProfileAvatarUrl.Valid {
url = &obj.ProfileAvatarUrl.String
}
profileIcon := &ProfileIcon{url, &obj.Initials, &obj.ProfileBgColor}
return profileIcon, nil
}
@ -554,39 +592,3 @@ type taskGroupResolver struct{ *Resolver }
type taskLabelResolver struct{ *Resolver }
type teamResolver struct{ *Resolver }
type userAccountResolver struct{ *Resolver }
// !!! WARNING !!!
// The code below was going to be deleted when updating resolvers. It has been copied here so you have
// one last chance to move it out of harms way if you want. There are two reasons this happens:
// - When renaming or deleting a resolver the old code will be put in here. You can safely delete
// it when you're done.
// - You have helper methods in this file. Move them out to keep these resolver files clean.
func (r *taskLabelResolver) ColorHex(ctx context.Context, obj *pg.TaskLabel) (string, error) {
projectLabel, err := r.Repository.GetProjectLabelByID(ctx, obj.ProjectLabelID)
if err != nil {
return "", err
}
labelColor, err := r.Repository.GetLabelColorByID(ctx, projectLabel.LabelColorID)
if err != nil {
return "", err
}
return labelColor.ColorHex, nil
}
func (r *taskLabelResolver) Name(ctx context.Context, obj *pg.TaskLabel) (*string, error) {
projectLabel, err := r.Repository.GetProjectLabelByID(ctx, obj.ProjectLabelID)
if err != nil {
return nil, err
}
name := projectLabel.Name
if !name.Valid {
return nil, err
}
return &name.String, err
}
func (r *projectLabelResolver) ColorHex(ctx context.Context, obj *pg.ProjectLabel) (string, error) {
labelColor, err := r.Repository.GetLabelColorByID(ctx, obj.LabelColorID)
if err != nil {
return "", err
}
return labelColor.ColorHex, nil
}