Modify the Resolver
Explore how to implement resolvers in Go to handle GraphQL operations such as user registration, login, and blog management. Understand how to integrate authentication middleware and configure the server to support these functionalities, enabling you to develop a complete GraphQL backend application.
Implement the resolver
Inside the schema.resolvers.go file, we implement all the resolvers.
Register
First, we implement the resolver for the registration.
Below is an explanation of the code above:
-
In line 3, the
r.userService.Register(input)function performs user registration. This function returns the JWT token. -
In line 11, if the registration succeeds, the JWT token is returned.
Login
We implement the resolver for the login.
Below is an explanation of the code above:
-
In line 3, the
r.userService.Login(input)function performs a login for the registered user. -
In line 11, if the login is successful, the JWT token is returned.
Create a new blog
We implement the resolver for creating a new blog.
Below is an explanation of the code above: ...