package resolver

// This file will be automatically regenerated based on the schema, any resolver implementations
// will be copied through when generating and any unknown code will be moved to the end.
// Code generated by github.com/99designs/gqlgen

import (
	"context"

	"github.com/cloudoperators/heureka/internal/api/graphql/graph"
	"github.com/cloudoperators/heureka/internal/api/graphql/graph/baseResolver"
	"github.com/cloudoperators/heureka/internal/api/graphql/graph/model"
)

// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and Greenhouse contributors
// SPDX-License-Identifier: Apache-2.0

// CreateUser is the resolver for the createUser field.
func (r *mutationResolver) CreateUser(ctx context.Context, input model.UserInput) (*model.User, error) {
	user := model.NewUserEntity(&input)
	newUser, err := r.App.CreateUser(&user)
	if err != nil {
		return nil, baseResolver.NewResolverError("CreateUserMutationResolver", "Internal Error - when creating user")
	}
	u := model.NewUser(newUser)
	return &u, nil
}

// UpdateUser is the resolver for the updateUser field.
func (r *mutationResolver) UpdateUser(ctx context.Context, id string, input model.UserInput) (*model.User, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateUserMutationResolver", "Internal Error - when updating user")
	}
	user := model.NewUserEntity(&input)
	user.Id = *idInt
	updatedUser, err := r.App.UpdateUser(&user)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateUserMutationResolver", "Internal Error - when updating user")
	}
	u := model.NewUser(updatedUser)
	return &u, nil
}

// DeleteUser is the resolver for the deleteUser field.
func (r *mutationResolver) DeleteUser(ctx context.Context, id string) (string, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteUserMutationResolver", "Internal Error - when deleting user")
	}
	err = r.App.DeleteUser(*idInt)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteUserMutationResolver", "Internal Error - when deleting user")
	}
	return id, nil
}

// CreateSupportGroup is the resolver for the createSupportGroup field.
func (r *mutationResolver) CreateSupportGroup(ctx context.Context, input model.SupportGroupInput) (*model.SupportGroup, error) {
	supportGroup := model.NewSupportGroupEntity(&input)
	newSupportGroup, err := r.App.CreateSupportGroup(&supportGroup)
	if err != nil {
		return nil, baseResolver.NewResolverError("CreateSupportGroupMutationResolver", "Internal Error - when creating supportGroup")
	}
	sg := model.NewSupportGroup(newSupportGroup)
	return &sg, nil
}

// UpdateSupportGroup is the resolver for the updateSupportGroup field.
func (r *mutationResolver) UpdateSupportGroup(ctx context.Context, id string, input model.SupportGroupInput) (*model.SupportGroup, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateSupportGroupMutationResolver", "Internal Error - when updating supportGroup")
	}
	supportGroup := model.NewSupportGroupEntity(&input)
	supportGroup.Id = *idInt
	updatedSupportGroup, err := r.App.UpdateSupportGroup(&supportGroup)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateSupportGroupMutationResolver", "Internal Error - when updating supportGroup")
	}
	sg := model.NewSupportGroup(updatedSupportGroup)
	return &sg, nil
}

// DeleteSupportGroup is the resolver for the deleteSupportGroup field.
func (r *mutationResolver) DeleteSupportGroup(ctx context.Context, id string) (string, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteSupportGroupMutationResolver", "Internal Error - when deleting supportGroup")
	}
	err = r.App.DeleteSupportGroup(*idInt)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteSupportGroupMutationResolver", "Internal Error - when deleting supportGroup")
	}
	return id, nil
}

// AddServiceToSupportGroup is the resolver for the addServiceToSupportGroup field.
func (r *mutationResolver) AddServiceToSupportGroup(ctx context.Context, supportGroupID string, serviceID string) (*model.SupportGroup, error) {
	supportGroupIdInt, err := baseResolver.ParseCursor(&supportGroupID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddServiceToSupportGroupMutationResolver", "Internal Error - when adding service to supportGroup")
	}

	serviceIdInt, err := baseResolver.ParseCursor(&serviceID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddServiceToSupportGroupMutationResolver", "Internal Error - when adding service to supportGroup")
	}

	supportGroup, err := r.App.AddServiceToSupportGroup(*supportGroupIdInt, *serviceIdInt)

	if err != nil {
		return nil, baseResolver.NewResolverError("AddServiceToSupportGroupMutationResolver", "Internal Error - when adding service to supportGroup")
	}

	sg := model.NewSupportGroup(supportGroup)
	return &sg, nil
}

// RemoveServiceFromSupportGroup is the resolver for the removeServiceFromSupportGroup field.
func (r *mutationResolver) RemoveServiceFromSupportGroup(ctx context.Context, supportGroupID string, serviceID string) (*model.SupportGroup, error) {
	supportGroupIdInt, err := baseResolver.ParseCursor(&supportGroupID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveServiceFromSupportGroupMutationResolver", "Internal Error - when removing service from supportGroup")
	}

	serviceIdInt, err := baseResolver.ParseCursor(&serviceID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveServiceFromSupportGroupMutationResolver", "Internal Error - when removing service from supportGroup")
	}

	supportGroup, err := r.App.RemoveServiceFromSupportGroup(*supportGroupIdInt, *serviceIdInt)

	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveServiceFromSupportGroupMutationResolver", "Internal Error - when removing service from supportGroup")
	}

	sg := model.NewSupportGroup(supportGroup)
	return &sg, nil
}

// AddUserToSupportGroup is the resolver for the addUserToSupportGroup field.
func (r *mutationResolver) AddUserToSupportGroup(ctx context.Context, supportGroupID string, userID string) (*model.SupportGroup, error) {
	supportGroupIdInt, err := baseResolver.ParseCursor(&supportGroupID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddUserToSupportGroupMutationResolver", "Internal Error - when adding user to supportGroup")
	}

	userIdInt, err := baseResolver.ParseCursor(&userID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddUserToSupportGroupMutationResolver", "Internal Error - when adding user to supportGroup")
	}

	supportGroup, err := r.App.AddUserToSupportGroup(*supportGroupIdInt, *userIdInt)

	if err != nil {
		return nil, baseResolver.NewResolverError("AddUserToSupportGroupMutationResolver", "Internal Error - when adding user to supportGroup")
	}

	sg := model.NewSupportGroup(supportGroup)
	return &sg, nil
}

// RemoveUserFromSupportGroup is the resolver for the removeUserFromSupportGroup field.
func (r *mutationResolver) RemoveUserFromSupportGroup(ctx context.Context, supportGroupID string, userID string) (*model.SupportGroup, error) {
	supportGroupIdInt, err := baseResolver.ParseCursor(&supportGroupID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveUserFromSupportGroupMutationResolver", "Internal Error - when removing user from supportGroup")
	}

	userIdInt, err := baseResolver.ParseCursor(&userID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveUserFromSupportGroupMutationResolver", "Internal Error - when removing user from supportGroup")
	}

	supportGroup, err := r.App.RemoveUserFromSupportGroup(*supportGroupIdInt, *userIdInt)

	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveUserFromSupportGroupMutationResolver", "Internal Error - when removing user from supportGroup")
	}

	sg := model.NewSupportGroup(supportGroup)
	return &sg, nil
}

// CreateComponent is the resolver for the createComponent field.
func (r *mutationResolver) CreateComponent(ctx context.Context, input model.ComponentInput) (*model.Component, error) {
	component := model.NewComponentEntity(&input)
	newComponent, err := r.App.CreateComponent(&component)
	if err != nil {
		return nil, baseResolver.NewResolverError("CreateComponentMutationResolver", "Internal Error - when creating component")
	}
	c := model.NewComponent(newComponent)
	return &c, nil
}

// UpdateComponent is the resolver for the updateComponent field.
func (r *mutationResolver) UpdateComponent(ctx context.Context, id string, input model.ComponentInput) (*model.Component, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateComponentMutationResolver", "Internal Error - when updating component")
	}
	component := model.NewComponentEntity(&input)
	component.Id = *idInt
	updatedComponent, err := r.App.UpdateComponent(&component)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateComponentMutationResolver", "Internal Error - when updating component")
	}
	c := model.NewComponent(updatedComponent)
	return &c, nil
}

// DeleteComponent is the resolver for the deleteComponent field.
func (r *mutationResolver) DeleteComponent(ctx context.Context, id string) (string, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteComponentMutationResolver", "Internal Error - when deleting component")
	}
	err = r.App.DeleteComponent(*idInt)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteComponentMutationResolver", "Internal Error - when deleting component")
	}
	return id, nil
}

// CreateComponentInstance is the resolver for the createComponentInstance field.
func (r *mutationResolver) CreateComponentInstance(ctx context.Context, input model.ComponentInstanceInput) (*model.ComponentInstance, error) {
	componentInstance := model.NewComponentInstanceEntity(&input)
	newComponentInstance, err := r.App.CreateComponentInstance(&componentInstance, input.UUID)
	if err != nil {
		return nil, baseResolver.NewResolverError("CreateComponentInstanceMutationResolver", "Internal Error - when creating componentInstance")
	}
	ci := model.NewComponentInstance(newComponentInstance)
	return &ci, nil
}

// UpdateComponentInstance is the resolver for the updateComponentInstance field.
func (r *mutationResolver) UpdateComponentInstance(ctx context.Context, id string, input model.ComponentInstanceInput) (*model.ComponentInstance, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateComponentInstanceMutationResolver", "Internal Error - when updating componentInstance")
	}
	componentInstance := model.NewComponentInstanceEntity(&input)
	componentInstance.Id = *idInt
	updatedComponentInstance, err := r.App.UpdateComponentInstance(&componentInstance, input.UUID)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateComponentInstanceMutationResolver", "Internal Error - when updating componentInstance")
	}
	ci := model.NewComponentInstance(updatedComponentInstance)
	return &ci, nil
}

// DeleteComponentInstance is the resolver for the deleteComponentInstance field.
func (r *mutationResolver) DeleteComponentInstance(ctx context.Context, id string) (string, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteComponentInstanceMutationResolver", "Internal Error - when deleting componentInstance")
	}
	err = r.App.DeleteComponentInstance(*idInt)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteComponentInstanceMutationResolver", "Internal Error - when deleting componentInstance")
	}
	return id, nil
}

// CreateComponentVersion is the resolver for the createComponentVersion field.
func (r *mutationResolver) CreateComponentVersion(ctx context.Context, input model.ComponentVersionInput) (*model.ComponentVersion, error) {
	componentVersion := model.NewComponentVersionEntity(&input)
	newComponentVersion, err := r.App.CreateComponentVersion(&componentVersion)
	if err != nil {
		return nil, baseResolver.NewResolverError("CreateComponentVersionMutationResolver", "Internal Error - when creating componentVersion")
	}
	cv := model.NewComponentVersion(newComponentVersion)
	return &cv, nil
}

// UpdateComponentVersion is the resolver for the updateComponentVersion field.
func (r *mutationResolver) UpdateComponentVersion(ctx context.Context, id string, input model.ComponentVersionInput) (*model.ComponentVersion, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateComponentVersionMutationResolver", "Internal Error - when updating componentVersion")
	}
	componentVersion := model.NewComponentVersionEntity(&input)
	componentVersion.Id = *idInt
	updatedComponentVersion, err := r.App.UpdateComponentVersion(&componentVersion)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateComponentVersionMutationResolver", "Internal Error - when updating componentVersion")
	}
	cv := model.NewComponentVersion(updatedComponentVersion)
	return &cv, nil
}

// DeleteComponentVersion is the resolver for the deleteComponentVersion field.
func (r *mutationResolver) DeleteComponentVersion(ctx context.Context, id string) (string, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteComponentVersionMutationResolver", "Internal Error - when deleting componentVersion")
	}
	err = r.App.DeleteComponentVersion(*idInt)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteComponentVersionMutationResolver", "Internal Error - when deleting componentVersion")
	}
	return id, nil
}

// CreateService is the resolver for the createService field.
func (r *mutationResolver) CreateService(ctx context.Context, input model.ServiceInput) (*model.Service, error) {
	service := model.NewServiceEntity(&input)
	newService, err := r.App.CreateService(&service)
	if err != nil {
		return nil, baseResolver.NewResolverError("CreateServiceMutationResolver", "Internal Error - when creating service")
	}
	s := model.NewService(newService)
	return &s, nil
}

// UpdateService is the resolver for the updateService field.
func (r *mutationResolver) UpdateService(ctx context.Context, id string, input model.ServiceInput) (*model.Service, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateServiceMutationResolver", "Internal Error - when updating service")
	}
	service := model.NewServiceEntity(&input)
	service.Id = *idInt
	updatedService, err := r.App.UpdateService(&service)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateServiceMutationResolver", "Internal Error - when updating service")
	}
	s := model.NewService(updatedService)
	return &s, nil
}

// DeleteService is the resolver for the deleteService field.
func (r *mutationResolver) DeleteService(ctx context.Context, id string) (string, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteServiceMutationResolver", "Internal Error - when deleting service")
	}
	err = r.App.DeleteService(*idInt)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteServiceMutationResolver", "Internal Error - when deleting service")
	}
	return id, nil
}

// AddOwnerToService is the resolver for the addOwnerToService field.
func (r *mutationResolver) AddOwnerToService(ctx context.Context, serviceID string, userID string) (*model.Service, error) {
	serviceIdInt, err := baseResolver.ParseCursor(&serviceID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddOwnerToServiceMutationResolver", "Internal Error - when adding owner to service")
	}

	userIdInt, err := baseResolver.ParseCursor(&userID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddOwnerToServiceMutationResolver", "Internal Error - when adding owner to service")
	}

	service, err := r.App.AddOwnerToService(*serviceIdInt, *userIdInt)

	if err != nil {
		return nil, baseResolver.NewResolverError("AddOwnerToServiceMutationResolver", "Internal Error - when adding owner to service")
	}

	s := model.NewService(service)
	return &s, nil
}

// RemoveOwnerFromService is the resolver for the removeOwnerFromService field.
func (r *mutationResolver) RemoveOwnerFromService(ctx context.Context, serviceID string, userID string) (*model.Service, error) {
	serviceIdInt, err := baseResolver.ParseCursor(&serviceID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveOwnerFromServiceMutationResolver", "Internal Error - when removing owner from service")
	}

	userIdInt, err := baseResolver.ParseCursor(&userID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveOwnerFromServiceMutationResolver", "Internal Error - when removing owner from service")
	}

	service, err := r.App.RemoveOwnerFromService(*serviceIdInt, *userIdInt)

	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveOwnerFromServiceMutationResolver", "Internal Error - when removing owner from service")
	}

	s := model.NewService(service)
	return &s, nil
}

// AddIssueRepositoryToService is the resolver for the addIssueRepositoryToService field.
func (r *mutationResolver) AddIssueRepositoryToService(ctx context.Context, serviceID string, issueRepositoryID string, priority int) (*model.Service, error) {
	serviceIdInt, err := baseResolver.ParseCursor(&serviceID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddIssueRepositoryToServiceMutationResolver", "Internal Error - when adding IssueRepository to service")
	}

	issueRepositoryIdInt, err := baseResolver.ParseCursor(&issueRepositoryID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddIssueRepositoryToServiceMutationResolver", "Internal Error - when adding IssueRepository to service")
	}

	service, err := r.App.AddIssueRepositoryToService(*serviceIdInt, *issueRepositoryIdInt, int64(priority))

	if err != nil {
		return nil, baseResolver.NewResolverError("AddIssueRepositoryToServiceMutationResolver", "Internal Error - when adding IssueRepository to service")
	}

	s := model.NewService(service)
	return &s, nil
}

// RemoveIssueRepositoryFromService is the resolver for the removeIssueRepositoryFromService field.
func (r *mutationResolver) RemoveIssueRepositoryFromService(ctx context.Context, serviceID string, issueRepositoryID string) (*model.Service, error) {
	serviceIdInt, err := baseResolver.ParseCursor(&serviceID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveIssueRepositoryFromServiceMutationResolver", "Internal Error - when removing IssueRepository from service")
	}

	issueRepositoryIdInt, err := baseResolver.ParseCursor(&issueRepositoryID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveIssueRepositoryFromServiceMutationResolver", "Internal Error - when removing IssueRepository from service")
	}

	service, err := r.App.RemoveIssueRepositoryFromService(*serviceIdInt, *issueRepositoryIdInt)

	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveIssueRepositoryFromServiceMutationResolver", "Internal Error - when removing IssueRepository from service")
	}

	s := model.NewService(service)
	return &s, nil
}

// CreateIssueRepository is the resolver for the createIssueRepository field.
func (r *mutationResolver) CreateIssueRepository(ctx context.Context, input model.IssueRepositoryInput) (*model.IssueRepository, error) {
	issueRepository := model.NewIssueRepositoryEntity(&input)
	newIssueRepository, err := r.App.CreateIssueRepository(&issueRepository)
	if err != nil {
		return nil, baseResolver.NewResolverError("CreateIssueRepositoryMutationResolver", "Internal Error - when creating issueRepository")
	}
	ir := model.NewIssueRepository(newIssueRepository)
	return &ir, nil
}

// UpdateIssueRepository is the resolver for the updateIssueRepository field.
func (r *mutationResolver) UpdateIssueRepository(ctx context.Context, id string, input model.IssueRepositoryInput) (*model.IssueRepository, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateIssueRepositoryMutationResolver", "Internal Error - when updating issueRepository")
	}
	issueRepository := model.NewIssueRepositoryEntity(&input)
	issueRepository.Id = *idInt
	updatedIssueRepository, err := r.App.UpdateIssueRepository(&issueRepository)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateIssueRepositoryMutationResolver", "Internal Error - when updating issueRepository")
	}
	ir := model.NewIssueRepository(updatedIssueRepository)
	return &ir, nil
}

// DeleteIssueRepository is the resolver for the deleteIssueRepository field.
func (r *mutationResolver) DeleteIssueRepository(ctx context.Context, id string) (string, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteIssueRepositoryMutationResolver", "Internal Error - when deleting issueRepository")
	}
	err = r.App.DeleteIssueRepository(*idInt)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteIssueRepositoryMutationResolver", "Internal Error - when deleting issueRepository")
	}
	return id, nil
}

// CreateIssue is the resolver for the createIssue field.
func (r *mutationResolver) CreateIssue(ctx context.Context, input model.IssueInput) (*model.Issue, error) {
	issue := model.NewIssueEntity(&input)
	newIssue, err := r.App.CreateIssue(&issue)
	if err != nil {
		return nil, baseResolver.NewResolverError("CreateIssueMutationResolver", "Internal Error - when creating issue")
	}
	i := model.NewIssue(newIssue)
	return &i, nil
}

// UpdateIssue is the resolver for the updateIssue field.
func (r *mutationResolver) UpdateIssue(ctx context.Context, id string, input model.IssueInput) (*model.Issue, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateIssueMutationResolver", "Internal Error - when updating issue")
	}
	issue := model.NewIssueEntity(&input)
	issue.Id = *idInt
	updatedIssue, err := r.App.UpdateIssue(&issue)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateIssueMutationResolver", "Internal Error - when updating issue")
	}
	i := model.NewIssue(updatedIssue)
	return &i, nil
}

// DeleteIssue is the resolver for the deleteIssue field.
func (r *mutationResolver) DeleteIssue(ctx context.Context, id string) (string, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteIssueMutationResolver", "Internal Error - when deleting issue")
	}
	err = r.App.DeleteIssue(*idInt)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteIssueMutationResolver", "Internal Error - when deleting issue")
	}
	return id, nil
}

// AddComponentVersionToIssue is the resolver for the addComponentVersionToIssue field.
func (r *mutationResolver) AddComponentVersionToIssue(ctx context.Context, issueID string, componentVersionID string) (*model.Issue, error) {
	issueIdInt, err := baseResolver.ParseCursor(&issueID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddComponentVersionToIssueMutationResolver", "Internal Error - when adding componentVersion to issue")
	}

	componentVersionIdInt, err := baseResolver.ParseCursor(&componentVersionID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddComponentVersionToIssueMutationResolver", "Internal Error - when adding componentVersion to issue")
	}

	issue, err := r.App.AddComponentVersionToIssue(*issueIdInt, *componentVersionIdInt)

	if err != nil {
		return nil, baseResolver.NewResolverError("AddComponentVersionToIssueMutationResolver", "Internal Error - when adding componentVersion to issue")
	}

	i := model.NewIssue(issue)
	return &i, nil
}

// RemoveComponentVersionFromIssue is the resolver for the removeComponentVersionFromIssue field.
func (r *mutationResolver) RemoveComponentVersionFromIssue(ctx context.Context, issueID string, componentVersionID string) (*model.Issue, error) {
	issueIdInt, err := baseResolver.ParseCursor(&issueID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveComponentVersionFromIssueMutationResolver", "Internal Error - when removing componentVersion from issue")
	}

	componentVersionIdInt, err := baseResolver.ParseCursor(&componentVersionID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveComponentVersionFromIssueMutationResolver", "Internal Error - when removing componentVersion from issue")
	}

	issue, err := r.App.RemoveComponentVersionFromIssue(*issueIdInt, *componentVersionIdInt)

	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveComponentVersionFromIssueMutationResolver", "Internal Error - when removing componentVersion from issue")
	}

	i := model.NewIssue(issue)
	return &i, nil
}

// CreateIssueVariant is the resolver for the createIssueVariant field.
func (r *mutationResolver) CreateIssueVariant(ctx context.Context, input model.IssueVariantInput) (*model.IssueVariant, error) {
	issueVariant := model.NewIssueVariantEntity(&input)
	newIssueVariant, err := r.App.CreateIssueVariant(&issueVariant)
	if err != nil {
		return nil, baseResolver.NewResolverError("CreateIssueVariantMutationResolver", "Internal Error - when creating issueVariant")
	}
	iv := model.NewIssueVariant(newIssueVariant)
	return &iv, nil
}

// UpdateIssueVariant is the resolver for the updateIssueVariant field.
func (r *mutationResolver) UpdateIssueVariant(ctx context.Context, id string, input model.IssueVariantInput) (*model.IssueVariant, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateIssueVariantMutationResolver", "Internal Error - when updating issueVariant")
	}
	issueVariant := model.NewIssueVariantEntity(&input)
	issueVariant.Id = *idInt
	updatedIssueVariant, err := r.App.UpdateIssueVariant(&issueVariant)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateIssueVariantMutationResolver", "Internal Error - when updating issueVariant")
	}
	iv := model.NewIssueVariant(updatedIssueVariant)
	return &iv, nil
}

// DeleteIssueVariant is the resolver for the deleteIssueVariant field.
func (r *mutationResolver) DeleteIssueVariant(ctx context.Context, id string) (string, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteIssueVariantMutationResolver", "Internal Error - when deleting issueVariant")
	}
	err = r.App.DeleteIssueVariant(*idInt)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteIssueVariantMutationResolver", "Internal Error - when deleting issueVariant")
	}
	return id, nil
}

// CreateEvidence is the resolver for the createEvidence field.
func (r *mutationResolver) CreateEvidence(ctx context.Context, input model.EvidenceInput) (*model.Evidence, error) {
	evidence := model.NewEvidenceEntity(&input)
	newEvidence, err := r.App.CreateEvidence(&evidence)
	if err != nil {
		return nil, baseResolver.NewResolverError("CreateEvidenceMutationResolver", "Internal Error - when creating evidence")
	}
	e := model.NewEvidence(newEvidence)
	return &e, nil
}

// UpdateEvidence is the resolver for the updateEvidence field.
func (r *mutationResolver) UpdateEvidence(ctx context.Context, id string, input model.EvidenceInput) (*model.Evidence, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateEvidenceMutationResolver", "Internal Error - when updating evidence")
	}
	evidence := model.NewEvidenceEntity(&input)
	evidence.Id = *idInt
	updatedEvidence, err := r.App.UpdateEvidence(&evidence)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateEvidenceMutationResolver", "Internal Error - when updating evidence")
	}
	e := model.NewEvidence(updatedEvidence)
	return &e, nil
}

// DeleteEvidence is the resolver for the deleteEvidence field.
func (r *mutationResolver) DeleteEvidence(ctx context.Context, id string) (string, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteEvidenceMutationResolver", "Internal Error - when deleting evidence")
	}
	err = r.App.DeleteEvidence(*idInt)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteEvidenceMutationResolver", "Internal Error - when deleting evidence")
	}
	return id, nil
}

// CreateIssueMatch is the resolver for the createIssueMatch field.
func (r *mutationResolver) CreateIssueMatch(ctx context.Context, input model.IssueMatchInput) (*model.IssueMatch, error) {
	issueMatch := model.NewIssueMatchEntity(&input)
	newIssueMatch, err := r.App.CreateIssueMatch(&issueMatch)
	if err != nil {
		return nil, baseResolver.NewResolverError("CreateIssueMatchMutationResolver", "Internal Error - when creating issueMatch")
	}
	im := model.NewIssueMatch(newIssueMatch)
	return &im, nil
}

// UpdateIssueMatch is the resolver for the updateIssueMatch field.
func (r *mutationResolver) UpdateIssueMatch(ctx context.Context, id string, input model.IssueMatchInput) (*model.IssueMatch, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateIssueMatchMutationResolver", "Internal Error - when updating issueMatch")
	}
	issueMatch := model.NewIssueMatchEntity(&input)
	issueMatch.Id = *idInt
	updatedIssueMatch, err := r.App.UpdateIssueMatch(&issueMatch)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateIssueMatchMutationResolver", "Internal Error - when updating issueMatch")
	}
	im := model.NewIssueMatch(updatedIssueMatch)
	return &im, nil
}

// DeleteIssueMatch is the resolver for the deleteIssueMatch field.
func (r *mutationResolver) DeleteIssueMatch(ctx context.Context, id string) (string, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteIssueMatchMutationResolver", "Internal Error - when deleting issueMatch")
	}
	err = r.App.DeleteIssueMatch(*idInt)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteIssueMatchMutationResolver", "Internal Error - when deleting issueMatch")
	}
	return id, nil
}

// AddEvidenceToIssueMatch is the resolver for the addEvidenceToIssueMatch field.
func (r *mutationResolver) AddEvidenceToIssueMatch(ctx context.Context, issueMatchID string, evidenceID string) (*model.IssueMatch, error) {
	issueMatchIdInt, err := baseResolver.ParseCursor(&issueMatchID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddEvidenceToIssueMatchMutationResolver", "Internal Error - when adding evidence to issueMatch")
	}

	evidenceIdInt, err := baseResolver.ParseCursor(&evidenceID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddEvidenceToIssueMatchMutationResolver", "Internal Error - when adding evidence to issueMatch")
	}

	issueMatch, err := r.App.AddEvidenceToIssueMatch(*issueMatchIdInt, *evidenceIdInt)

	if err != nil {
		return nil, baseResolver.NewResolverError("AddEvidenceToIssueMatchMutationResolver", "Internal Error - when adding evidence to issueMatch")
	}

	im := model.NewIssueMatch(issueMatch)
	return &im, nil
}

// RemoveEvidenceFromIssueMatch is the resolver for the removeEvidenceFromIssueMatch field.
func (r *mutationResolver) RemoveEvidenceFromIssueMatch(ctx context.Context, issueMatchID string, evidenceID string) (*model.IssueMatch, error) {
	issueMatchIdInt, err := baseResolver.ParseCursor(&issueMatchID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveEvidenceFromIssueMatchMutationResolver", "Internal Error - when removing evidence from issueMatch")
	}

	evidenceIdInt, err := baseResolver.ParseCursor(&evidenceID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveEvidenceFromIssueMatchMutationResolver", "Internal Error - when removing evidence from issueMatch")
	}

	issueMatch, err := r.App.RemoveEvidenceFromIssueMatch(*issueMatchIdInt, *evidenceIdInt)

	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveEvidenceFromIssueMatchMutationResolver", "Internal Error - when removing evidence from issueMatch")
	}

	im := model.NewIssueMatch(issueMatch)
	return &im, nil
}

// CreateIssueMatchChange is the resolver for the createIssueMatchChange field.
func (r *mutationResolver) CreateIssueMatchChange(ctx context.Context, input model.IssueMatchChangeInput) (*model.IssueMatchChange, error) {
	issueMatchChange := model.NewIssueMatchChangeEntity(&input)
	newIssueMatchChange, err := r.App.CreateIssueMatchChange(&issueMatchChange)
	if err != nil {
		return nil, baseResolver.NewResolverError("CreateIssueMatchChangeMutationResolver", "Internal Error - when creating issueMatchChange")
	}
	imc := model.NewIssueMatchChange(newIssueMatchChange)
	return &imc, nil
}

// UpdateIssueMatchChange is the resolver for the updateIssueMatchChange field.
func (r *mutationResolver) UpdateIssueMatchChange(ctx context.Context, id string, input model.IssueMatchChangeInput) (*model.IssueMatchChange, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateIssueMatchChangeMutationResolver", "Internal Error - when updating issueMatchChange")
	}
	issueMatchChange := model.NewIssueMatchChangeEntity(&input)
	issueMatchChange.Id = *idInt
	updatedIssueMatchChange, err := r.App.UpdateIssueMatchChange(&issueMatchChange)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateIssueMatchChangeMutationResolver", "Internal Error - when updating issueMatchChange")
	}
	imc := model.NewIssueMatchChange(updatedIssueMatchChange)
	return &imc, nil
}

// DeleteIssueMatchChange is the resolver for the deleteIssueMatchChange field.
func (r *mutationResolver) DeleteIssueMatchChange(ctx context.Context, id string) (string, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteIssueMatchChangeMutationResolver", "Internal Error - when deleting issueMatchChange")
	}
	err = r.App.DeleteIssueMatchChange(*idInt)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteIssueMatchChangeMutationResolver", "Internal Error - when deleting issueMatchChange")
	}
	return id, nil
}

// CreateActivity is the resolver for the createActivity field.
func (r *mutationResolver) CreateActivity(ctx context.Context, input model.ActivityInput) (*model.Activity, error) {
	activity := model.NewActivityEntity(&input)
	newActivity, err := r.App.CreateActivity(&activity)
	if err != nil {
		return nil, baseResolver.NewResolverError("CreateActivityMutationResolver", "Internal Error - when creating activity")
	}
	a := model.NewActivity(newActivity)
	return &a, nil
}

// UpdateActivity is the resolver for the updateActivity field.
func (r *mutationResolver) UpdateActivity(ctx context.Context, id string, input model.ActivityInput) (*model.Activity, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateActivityMutationResolver", "Internal Error - when updating activity")
	}
	activity := model.NewActivityEntity(&input)
	activity.Id = *idInt
	updatedActivity, err := r.App.UpdateActivity(&activity)
	if err != nil {
		return nil, baseResolver.NewResolverError("UpdateActivityMutationResolver", "Internal Error - when updating activity")
	}
	a := model.NewActivity(updatedActivity)
	return &a, nil
}

// DeleteActivity is the resolver for the deleteActivity field.
func (r *mutationResolver) DeleteActivity(ctx context.Context, id string) (string, error) {
	idInt, err := baseResolver.ParseCursor(&id)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteActivityResolver", "Internal Error - when deleting activity")
	}
	err = r.App.DeleteActivity(*idInt)
	if err != nil {
		return "", baseResolver.NewResolverError("DeleteActivityMutationResolver", "Internal Error - when deleting activity")
	}
	return id, nil
}

// AddServiceToActivity is the resolver for the addServiceToActivity field.
func (r *mutationResolver) AddServiceToActivity(ctx context.Context, activityID string, serviceID string) (*model.Activity, error) {
	activityIdInt, err := baseResolver.ParseCursor(&activityID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddServiceToActivityMutationResolver", "Internal Error - when adding service to activity")
	}

	serviceIdInt, err := baseResolver.ParseCursor(&serviceID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddServiceToActivityMutationResolver", "Internal Error - when adding service to activity")
	}

	activity, err := r.App.AddServiceToActivity(*activityIdInt, *serviceIdInt)

	if err != nil {
		return nil, baseResolver.NewResolverError("AddServiceToActivityMutationResolver", "Internal Error - when adding service to activity")
	}

	a := model.NewActivity(activity)
	return &a, nil
}

// RemoveServiceFromActivity is the resolver for the removeServiceFromActivity field.
func (r *mutationResolver) RemoveServiceFromActivity(ctx context.Context, activityID string, serviceID string) (*model.Activity, error) {
	activityIdInt, err := baseResolver.ParseCursor(&activityID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveServiceFromActivityMutationResolver", "Internal Error - when removing service from activity")
	}

	serviceIdInt, err := baseResolver.ParseCursor(&serviceID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveServiceFromActivityMutationResolver", "Internal Error - when removing service from activity")
	}

	activity, err := r.App.RemoveServiceFromActivity(*activityIdInt, *serviceIdInt)

	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveServiceFromActivityMutationResolver", "Internal Error - when removing service from activity")
	}

	a := model.NewActivity(activity)
	return &a, nil
}

// AddIssueToActivity is the resolver for the addIssueToActivity field.
func (r *mutationResolver) AddIssueToActivity(ctx context.Context, activityID string, issueID string) (*model.Activity, error) {
	activityIdInt, err := baseResolver.ParseCursor(&activityID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddIssueToActivityMutationResolver", "Internal Error - when adding issue to activity")
	}

	issueIdInt, err := baseResolver.ParseCursor(&issueID)
	if err != nil {
		return nil, baseResolver.NewResolverError("AddIssueToActivityMutationResolver", "Internal Error - when adding issue to activity")
	}

	activity, err := r.App.AddIssueToActivity(*activityIdInt, *issueIdInt)

	if err != nil {
		return nil, baseResolver.NewResolverError("AddIssueToActivityMutationResolver", "Internal Error - when adding issue to activity")
	}

	a := model.NewActivity(activity)
	return &a, nil
}

// RemoveIssueFromActivity is the resolver for the removeIssueFromActivity field.
func (r *mutationResolver) RemoveIssueFromActivity(ctx context.Context, activityID string, issueID string) (*model.Activity, error) {
	activityIdInt, err := baseResolver.ParseCursor(&activityID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveIssueFromActivityMutationResolver", "Internal Error - when removing issue from activity")
	}

	issueIdInt, err := baseResolver.ParseCursor(&issueID)
	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveIssueFromActivityMutationResolver", "Internal Error - when removing issue from activity")
	}

	activity, err := r.App.RemoveIssueFromActivity(*activityIdInt, *issueIdInt)

	if err != nil {
		return nil, baseResolver.NewResolverError("RemoveIssueFromActivityMutationResolver", "Internal Error - when removing issue from activity")
	}

	a := model.NewActivity(activity)
	return &a, nil
}

func (r *mutationResolver) CreateScannerRun(ctx context.Context, input model.ScannerRunInput) (bool, error) {
	scannerRun := model.NewScannerRunEntity(&input)
	_, err := r.App.CreateScannerRun(&scannerRun)
	if err != nil {
		return false, baseResolver.NewResolverError("CreateScannerRunMutationResolver", "Internal Error - when creating scannerRun")
	}

	return true, nil
}

func (r *mutationResolver) CompleteScannerRun(ctx context.Context, uuid string) (bool, error) {
	_, err := r.App.CompleteScannerRun(uuid)
	if err != nil {
		return false, baseResolver.NewResolverError("CompleteScannerRunMutationResolver", "Internal Error - when completing scannerRun")
	}
	return true, nil
}

func (r *mutationResolver) FailScannerRun(ctx context.Context, uuid string, message string) (bool, error) {
	_, err := r.App.FailScannerRun(uuid, message)
	if err != nil {
		return false, baseResolver.NewResolverError("FailScannerRunMutationResolver", "Internal Error - when failing scannerRun")
	}
	return true, nil
}

func (r *Resolver) Mutation() graph.MutationResolver { return &mutationResolver{r} }

type mutationResolver struct{ *Resolver }
