This GraphQL endpoint provides functionality for managing users data and their orders.
You can view the full documentation for this application here.
The documentation provides detailed information about the API endpoints, usage instructions, and other essential resources.
You can send GraphQL requests to the designated endpoint in the documentation with appropriate query and mutation operations along with necessary variables.
- Make sure you have NodeJS installed on your system. The version used on this project was
v18.18.2. - Although npm comes with NodeJS, do make sure you have npm installed also. The version used on this project was
v9.8.1. - Ensure that you have an active instance of mysql running.
- Create a file .env in the root directory, if it doesn't exist and insert the following information:
- DB_USERNAME=your_username
- DB_PASSWORD=your_password
- DB_DATABASE=your_database
- DB_HOST=your_sql_host
- DB_DIALECT=mysql
- PORT=4000Use the package manager npm to install the necessary dependencies.
npm install- You can run the application by typing one of the following commands on your preferred terminal.
npm start
npm run start
node ./src/app.js- Open any GraphQL playground of your choice and go to the Url specified in the console as to where the server is running, e.g
http://localhost:4000/graphql - Once the server starts running, 1000 records are added to the User Table and 5000 records of Orders to the Order Table, but this wouldn't be done in subsequent server initializations.
- Explore the capabilities of the endpoint.
- A major concern for me is the task to grab the top ten users with the most orders placed, though it wasn't specified to create an endpoint for that, the function for getting it along
with the query is in the
UserService.jsfile in the directorysrc/serviceswith a function namedgetTopTenUsersByMostOrders. - If you're having any issues in running the application, Please reach out to me here.
- You can also view the hosted version here.
- Amadiegwu Ndunuju Emmanuel