Service Component Creation for GraphQL
Learn how to create a service component in the GraphQL application.
Create a service component
Before creating a service component, we create a new directory inside the graph directory called service. Then, we add a service component in the service.go.
Service component for the application
In the code above, there are two main components:
-
BlogService: Acts as a service component that is used by the resolver. -
storage: Acts as local storage for the application.
Get all blogs
We create a function to get all blogs called GetAllBlogs.
Get all blogs
In the code above, the function simply returns all blogs.