Implementing the post service
Let's now generate and implement the post service, which encapsulates the methods for creating and removing posts, as well as uploading images, after we've generated the types and services and configured the paths. Simply inject the generated CreatePostGQL
, RemovePostGQL
, and UploadFileGQL
services and call their mutate()
method with the necessary arguments to send the mutations to the backend:
- To generate a post service in the
core/
folder, open your terminal and run the following command:ng g s core/services/post/post
Next, create the core/services/index.ts
file and export the existing services to the import paths from within the core/
folder:
export { AuthService } from './auth/auth.service'; export { PostService } from './post/post.service';
Also, open the core/index.ts
file and update it as follows:
export { AuthService, PostService } from '...