resolve conflicts

This commit is contained in:
Hongbo Wu
2023-09-19 17:28:07 +08:00
parent b2fbbfb073
commit e696709a69

View File

@ -28,6 +28,7 @@ import {
UpdateLabelSuccess,
} from '../../generated/graphql'
import { labelRepository } from '../../repository/label'
import { userRepository } from '../../repository/user'
import {
findOrCreateLabels,
saveLabelsInHighlight,
@ -40,6 +41,13 @@ import { authorized } from '../../utils/helpers'
export const labelsResolver = authorized<LabelsSuccess, LabelsError>(
async (_obj, _params, { authTrx, log, uid }) => {
try {
const user = await userRepository.findById(uid)
if (!user) {
return {
errorCodes: [LabelsErrorCode.Unauthorized],
}
}
const labels = await authTrx(async (tx) => {
return tx.withRepository(labelRepository).find({
order: {