Skip to content

Commit 145ae49

Browse files
committed
add branding to sub resolver, check if logo/favicon exists on SubBranding upsert
1 parent c8be9ab commit 145ae49

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

api/resolvers/sub.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,20 @@ export default {
318318

319319
await validateSchema(subBrandingSchema, branding)
320320

321+
if (branding.logoId) {
322+
const upload = await models.upload.findUnique({ where: { id: Number(branding.logoId) } })
323+
if (!upload) {
324+
throw new GqlInputError('logo not found')
325+
}
326+
}
327+
328+
if (branding.faviconId) {
329+
const upload = await models.upload.findUnique({ where: { id: Number(branding.faviconId) } })
330+
if (!upload) {
331+
throw new GqlInputError('favicon not found')
332+
}
333+
}
334+
321335
return await models.subBranding.upsert({
322336
where: { subName },
323337
update: { ...branding, subName },
@@ -359,6 +373,9 @@ export default {
359373
domain: async (sub, args, { models }) => {
360374
return models.domain.findUnique({ where: { subName: sub.name } })
361375
},
376+
branding: async (sub, args, { models }) => {
377+
return models.subBranding.findUnique({ where: { subName: sub.name } })
378+
},
362379
createdAt: sub => sub.createdAt || sub.created_at
363380
}
364381
}

0 commit comments

Comments
 (0)