We are now going to edit our GraphQL schema and implement the matching resolver function. Let's start with the schema and a new mutation to the RootMutation object of our schema.js file:
login ( email: String! password: String!): Auth
The preceding schema gives us a login mutation that accepts an email address and a password. Both are required to identify and authenticate the user. We then need to respond with something to the client. For now, the Auth type returns a token, which is a JWT in our case. You might want to add a different option according to your requirements:
type Auth { token: String}
The schema is now ready. Head over to the resolvers file and add the login function inside the mutation object. Before ...