Complete the resolver code to fetch all users using Prisma.
const resolvers = { Query: { users: async () => await prisma.user.[1]() } };The Prisma client uses findMany to fetch multiple records. So prisma.user.findMany is the correct method.
Complete the resolver code to fetch all posts using Prisma client.
const resolvers = { Query: { posts: async () => await prisma.post.[1]() } };To fetch multiple records in Prisma, use findMany(). Other options are not valid Prisma methods.
Fix the error in the mutation to create a new user with Prisma.
mutation { createUser(data: { name: "Alice", email: "alice@example.com" }) { [1] } }In GraphQL mutations, after calling the mutation, you specify the fields you want returned. Here, id name email are the fields to return.
Fill both blanks to write a Prisma query that finds a unique user by email.
const user = await prisma.user.[1]({ where: { email: [2] } });
findUnique is used to find a single record by a unique field. The email value must be a string, so it needs quotes.
Fill all three blanks to write a mutation that updates a user's name by id using Prisma.
const updatedUser = await prisma.user.[1]({ where: { id: [2] }, data: { name: [3] } });
update is the Prisma method to update a record. The id is a number, and the new name is a string, so it needs quotes.