Update error handling

This commit is contained in:
Barry Low committed 2018-11-01 08:46:02 -07:00
1 parent d43648e1c9
commit f1fe0510b1
7 files changed
+81 -25

No files matched your search

+6 -3
View File
@@ -1,4 +1,4 @@
import { logger } from '../../../logger'
import { logger, AuthenticationError } from '../../../logger'
import TEAMS_CONNECTIONS_FRAGMENT from '../../fragments/TeamsConnectionsFragment'
import TEAMS_FRAGMENT from '../../fragments/TeamsFragment'
@@ -9,8 +9,10 @@ export const teams = async (parent, args, ctx, info) => {
return ctx.db.query.teamsConnection({}, TEAMS_CONNECTIONS_FRAGMENT)
}
export const teamById = async (parent, { id }, ctx, info) => {
return ctx.db.query.team({ where: { id } }, info)
export const teamById = async (parent, { teamId }, ctx, info) => {
logger.info('teamById')
logger.info(teamId)
return ctx.db.query.team({ where: { id: teamId } }, info)
}
export const teamByName = async (parent, { name }, ctx, info) => {
@@ -26,6 +28,7 @@ export const teamsByOwner = async (parent, args, ctx, info) => {
const authId = ctx.request.headers.userid
if (!authId) {
throw new AuthenticationError()
return
}
return ctx.db.query.teams({where: { owner: authId }, orderBy:'updatedAt_DESC'}, TEAMS_FRAGMENT)
}