chore: update biome configuration and enhance error handling in schema files
- Enabled useIgnoreFile in biome.json for better file management. - Updated various correctness and style rules in biome.json to enforce stricter coding standards. - Added new biome lint command in package.json for improved code quality checks. - Refactored error handling in multiple schema files to use consistent error throwing patterns, enhancing readability and maintainability. - Improved user authentication checks across various schemas to ensure proper access control.
This commit is contained in:
@@ -185,9 +185,13 @@ export class UserSchema extends PothosSchema {
|
||||
take: t.arg({ type: 'Int', required: false }),
|
||||
},
|
||||
resolve: async (_parent, args, ctx) => {
|
||||
if (ctx.isSubscription) throw new Error('Not allowed')
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
const me = ctx.http.me
|
||||
if (!me) throw new Error('User not found')
|
||||
if (!me) {
|
||||
throw new Error('User not found')
|
||||
}
|
||||
|
||||
// get chat rooms that the user is a part of
|
||||
const chatRooms = await this.prisma.chatRoom.findMany({
|
||||
@@ -212,7 +216,9 @@ export class UserSchema extends PothosSchema {
|
||||
},
|
||||
})
|
||||
|
||||
if (!lastMessage) return null
|
||||
if (!lastMessage) {
|
||||
return null
|
||||
}
|
||||
|
||||
const sender = lastMessage.senderId
|
||||
? await this.prisma.user.findUnique({
|
||||
@@ -257,7 +263,9 @@ export class UserSchema extends PothosSchema {
|
||||
...query,
|
||||
where: args.where,
|
||||
})
|
||||
if (!user) throw new Error('User not found')
|
||||
if (!user) {
|
||||
throw new Error('User not found')
|
||||
}
|
||||
return user
|
||||
},
|
||||
}),
|
||||
@@ -540,7 +548,9 @@ export class UserSchema extends PothosSchema {
|
||||
userScopedMessage: t.field({
|
||||
type: this.messageSchema.message(),
|
||||
subscribe: async (_, _args, ctx: SchemaContext) => {
|
||||
if (!ctx.isSubscription) throw new Error('Not allowed')
|
||||
if (!ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
const {
|
||||
websocket: { pubSub },
|
||||
} = ctx
|
||||
|
||||
Reference in New Issue
Block a user