Connecting the frontend and backend
The most interesting part is how we structure our API requests to accommodate maintainability and easy adaptability, following the best practices we have learned from the previous chapters.
The following screenshot shows our folder structure containing the GraphQL endpoints according to the features we currently have in our application and in the Strapi backend we developed for this project:
Figure 6.12 – A screenshot of the new folder structure with GraphQL and Strapi
In the graphql
folder, we have defined three folders, namely auth
, photos
, and users
, which represent the features our current project will have. Let’s look at what these folders contain.
The auth folder
The auth
folder contains only a single mutation which will handle all the authentication and authorization functionalities. It will contain mutations, such as register
, login
, forgotPassword
, sendForgotPasswordEmail
, and so on.