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:
2024-12-08 21:01:26 +07:00
parent 10e20092ab
commit 45dca51990
17 changed files with 430 additions and 159 deletions

View File

@@ -65,8 +65,12 @@ export class PersonalMilestoneSchema extends PothosSchema {
args: this.builder.generator.findUniqueArgs('PersonalMilestone'),
description: 'Retrieve a single personal milestone by its unique identifier.',
resolve: async (_query, _root, args, ctx, _info) => {
if (ctx.isSubscription) throw new Error('Not allowed')
if (!ctx.http.me) throw new Error('Cannot get your info')
if (ctx.isSubscription) {
throw new Error('Not allowed')
}
if (!ctx.http.me) {
throw new Error('Cannot get your info')
}
return this.prisma.personalMilestone.findUnique({
where: args.where,
})
@@ -77,8 +81,12 @@ export class PersonalMilestoneSchema extends PothosSchema {
args: this.builder.generator.findManyArgs('PersonalMilestone'),
description: 'Retrieve multiple personal milestones.',
resolve: async (_query, _root, args, ctx, _info) => {
if (ctx.isSubscription) throw new Error('Not allowed')
if (!ctx.http.me) throw new Error('Cannot get your info')
if (ctx.isSubscription) {
throw new Error('Not allowed')
}
if (!ctx.http.me) {
throw new Error('Cannot get your info')
}
return this.prisma.personalMilestone.findMany({
where: args.filter ?? undefined,
orderBy: args.orderBy ?? undefined,