Complete the code to define a GraphQL query that fetches all users.
type Query { users: [1] }The users query returns a list of User objects, so the type is [User].
Complete the resolver function to fetch users from the database.
const resolvers = { Query: { users: async () => await [1].find() } }The resolver calls the database model UserModel to find all users.
Fix the error in the GraphQL schema to correctly define a user type with id and name.
type User { id: ID! name: [1]! }The name field should be a String type in GraphQL.
Fill both blanks to write a resolver that fetches a user by id from the database.
const resolvers = { Query: { user: async (_, [1]) => await UserModel.[2]({ id: id }) } }The resolver receives arguments as 'args' and uses 'findOne' to get a single user by id.
Fill all three blanks to define a mutation that adds a new user with name and returns the created user.
type Mutation { addUser(name: [1]!): [2] } const resolvers = { Mutation: { addUser: async (_, [3]) => { const user = new UserModel({ name: name }); await user.save(); return user; } } }The mutation takes a name of type String, returns a User type, and receives arguments as 'args'.