Backend API for Upath's self studying dashboard using the following technology stack: PostgresQL Database, GraphQL Apollo Server for API requests, Node Js Runtime and Express Backend Framework built using Typescript
The URL endpoint that was deployed to heroku is:
https://upathorg-dashboard-backend.herokuapp.com/graphql
If you want to run it on your localhost, then follow the following commands below
npm install
This installs the npm dependencies in the package.json file
npm install -g nodemon
This installs nodemon globally (optional: for some users you need to add sudo before the npm install)
The databse created is hosted on heroku
Run this command to start a development server using nodemon
npm run dev
This runs your local server.
Enter the URL of the local server on your browser and enter this command on the graphiql client user interface to test if the app is working
{
students{
firstName
lastName
email
courses{
title
description
}
}
}
If you see the output below, then this confirms the app is working
{
{
"data": {
"students": [
{
"firstName": "Tony",
"lastName": "Stark",
"email": "ironman@gmail.com",
"courses": [
{
"title": "Node Crash Course",
"description": "Web dev Backend"
},
{
"title": "GraphQL Apollo server course",
"description": "Backend web dev/API"
}
]
},
{
"firstName": "Steve",
"lastName": "Rodgers",
"email": "captainamerica@gmail.com",
"courses": [
{
"title": "GraphQL Apollo server course",
"description": "Backend web dev/API"
}
]
},
{
"firstName": "Thor",
"lastName": "Odinson",
"email": "godofthunder@gmail.com",
"courses": [
{
"title": "GraphQL Apollo server course",
"description": "Backend web dev/API"
},
{
"title": "Node Crash Course",
"description": "Web dev Backend"
}
]
},
{
"firstName": "Doctor",
"lastName": "Strange",
"email": "drstrange@gmail.com",
"courses": []
}
]
}
}
Enter the command below in the graphql test client
mutation {
createStudent(
firstName: "Peter"
lastName: "Parker"
username: "spiderman"
email: "spiderman@gmail.com"
){
success
message
student{
firstName
lastName
email
}
}
}
The following results should be returned
{
"data": {
"createStudent": {
"success": true,
"message": "student Created Successfully",
"student": {
"firstName": "Doctor",
"lastName": "Strange",
"email": "drstrange@gmail.com"
}
}
}
}
Enter the command below in the graphql test client
mutation {
updateStudent(
id: 4
username: "spiderman_updated"
email: "spiderman@gmail.com"
){
success
message
student{
firstName
lastName
email
}
}
}
Enter the following command to delete data from the database
mutation {
deleteStudent(id: 2){
success
message
user{
id
firstName
}
}
}
When you are ready to compile your typescript project to Javascript, run this command
npm run build
This builds your project into dist folder
When you are ready to test the final compiled files, run this command
npm run start