mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
log errors in message and location resolvers
This commit is contained in:
parent
0aa8632146
commit
60e986c6bd
@ -5,6 +5,8 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
||||
import { UserInputError } from 'apollo-server'
|
||||
|
||||
import type { Context } from '@src/server'
|
||||
|
||||
import Resolver from './helpers/Resolver'
|
||||
import { queryLocations } from './users/location'
|
||||
|
||||
@ -25,7 +27,7 @@ export default {
|
||||
}),
|
||||
distanceToMe: async (parent, _params, context, _resolveInfo) => {
|
||||
if (!parent.id) {
|
||||
throw new Error('Can not identify selected Location!')
|
||||
throw new UserInputError('Can not identify selected Location!')
|
||||
}
|
||||
const session = context.driver.session()
|
||||
|
||||
@ -53,11 +55,12 @@ export default {
|
||||
},
|
||||
},
|
||||
Query: {
|
||||
queryLocations: async (_object, args, _context, _resolveInfo) => {
|
||||
queryLocations: async (_object, args, context: Context, _resolveInfo) => {
|
||||
try {
|
||||
return queryLocations(args)
|
||||
} catch (e) {
|
||||
throw new UserInputError(e.message)
|
||||
context.logger.error('queryLocations', e)
|
||||
throw new Error(e.message)
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@ -24,6 +24,12 @@ let mutate
|
||||
let authenticatedUser
|
||||
let chattingUser, otherChattingUser, notChattingUser
|
||||
|
||||
const loggerErrorMock: (e) => void = jest.fn()
|
||||
|
||||
jest.mock('@src/logger', () => ({
|
||||
error: (e) => loggerErrorMock(e),
|
||||
}))
|
||||
|
||||
const database = databaseContext()
|
||||
const pubsub = pubsubContext()
|
||||
const pubsubSpy = jest.spyOn(pubsub, 'publish')
|
||||
|
||||
@ -9,6 +9,7 @@ import { neo4jgraphql } from 'neo4j-graphql-js'
|
||||
|
||||
import CONFIG, { isS3configured } from '@config/index'
|
||||
import { CHAT_MESSAGE_ADDED } from '@constants/subscriptions'
|
||||
import type { Context } from '@src/server'
|
||||
|
||||
import { attachments } from './attachments/attachments'
|
||||
import Resolver from './helpers/Resolver'
|
||||
@ -71,7 +72,7 @@ export default {
|
||||
},
|
||||
},
|
||||
Mutation: {
|
||||
CreateMessage: async (_parent, params, context, _resolveInfo) => {
|
||||
CreateMessage: async (_parent, params, context: Context, _resolveInfo) => {
|
||||
const { roomId, content, files = [] } = params
|
||||
const {
|
||||
user: { id: currentUserId },
|
||||
@ -145,6 +146,7 @@ export default {
|
||||
|
||||
return await writeTxResultPromise
|
||||
} catch (error) {
|
||||
context.logger.error('CreateMessage', error)
|
||||
throw new Error(error)
|
||||
} finally {
|
||||
session.close()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user