Resolver Component Creation for GraphQL
Learn how to create a resolver component in the GraphQL application.
Implement the resolver
We start by registering the service component in the resolver so the resolver can implement the functionalities with the component. We implement the functionalities inside the schema.resolvers.go
file.
Create a new blog
Inside the NewBlog()
function, we create an implementation to add new blog data.
func (r *mutationResolver) NewBlog(ctx context.Context, input model.NewBlog) (*model.Blog, error) {
var blog *model.Blog = r.blogService.CreateBlog(input)
return blog, nil
}
In the code above, the new blog is created with the CreateBlog()
function ...