Front-end applications needing to communicate with services that deliver data and generally these services use HTTP
Following our example, let's create a folder calledSchemainsidesrc/domains/General/Category. Within this folder, create a file calledCategoryService.js, with asrc/domains/General/Category/Schema/CategoryService.js path at the end.
These paths may vary according to the needs of each one and are here only as a suggestion. With a little experience it is possible to understand what is being done and use it as you see fit
The content of this document will be a class similar to the excerpt below. When extending theRestclass, theCategoryServiceclass inherits all of its behavior. These behaviors include methods that create, read, update and delete resources from theCategoryentity.
Note the use of theresourceproperty that is imported from settings.js. To know more details about Serviceswithin the project visit this page.
There is no class to consume resources using GraphQL,but the logic is basically the same and with some knowledge of JavaScript it is possible to create an abstraction for this type of service as well.
This class will be used next to provide access to the entity's endpoints, let's move on to the next step.