refactor: enhance room resolvers with authentication

This commit is contained in:
Juan Sebastián Montoya 2025-03-24 13:45:52 -05:00
parent f9f85423b4
commit f5638d0e84

View file

@ -1,23 +1,23 @@
import { GraphQLError } from 'graphql';
import { IResolvers } from 'mercurius';
import { withAuth } from '../utils';
import { MutationResolvers } from '../generated/graphql';
import { MutationResolvers, QueryResolvers } from '../generated/graphql';
export const ROOM_ADDED = 'ROOM_ADDED';
export const ROOM_UPDATED = 'ROOM_UPDATED';
export const roomResolvers: IResolvers = {
Query: {
rooms: async (_, __, { prisma }) => {
rooms: withAuth<QueryResolvers['rooms']>(async (_, __, { prisma }) => {
return prisma.room.findMany({
where: { isPrivate: false },
});
},
room: async (_, { id }, { prisma }) => {
}),
room: withAuth<QueryResolvers['room']>(async (_, { id }, { prisma }) => {
return prisma.room.findUnique({
where: { id },
});
},
}),
},
Mutation: {
createRoom: withAuth<MutationResolvers['createRoom']>(