Integrating authentication with GraphQL resolvers
Integrating authentication into GraphQL isn't much different from adding any other functionality. In this section, we'll learn how to do that.
Let's now integrate our authentication-related calls. Let's start with the register
call:
- You'll recall we already created our
register
call in Chapter 14, Setting Up Postgres and Repository Layer with TypeORM. So now, let's add ourtypeDefs
andresolvers
. First, add theregister
call from the source code, to thetypeDefs
file in theMutation
section: - Now, in our resolvers file, in the
Mutation
section, add the code from our GitHub source code.This is again just a wrapper of our repository call so there's not much to explain, but notice we do not return a
User
object; we only return a status message. This is because we want to reduce the chance of any unnecessary information being spilled out. Before we try running it, let's enable our GraphQL...