mongoose graphql shacdn next setup completed

This commit is contained in:
2025-11-13 15:42:26 +03:00
parent a5bdcb9705
commit 053586c5cc
34 changed files with 9309 additions and 2 deletions

View File

@@ -0,0 +1,21 @@
// graphql/resolvers/userResolvers.ts
import { connectDB } from '@/lib/mongodb';
import User from '@/models/User';
export const userResolvers = {
Query: {
users: async () => {
await connectDB();
const users = await User.find().lean();
return users;
},
},
Mutation: {
addUser: async (_: any, { name, email }: { name: string; email: string }) => {
await connectDB();
const user = new User({ name, email });
await user.save();
return user;
},
},
};