- Stateless ,client independent API for data exchange.
- We always send all data back to the client from an endpoint.
- If we want some less data we'll need to create a new endpoint in backend or we'll send parameters for the data we need.
- GET/POST/PUT/... requests.
- Routes & Controllers.
- Stateless ,client independent API for data exchange with higher query flexibility.
- No problem here regarding queries (very flexible).
- Only POST requests for every type of request to one single endpoint.
- Operation definitions and Resolvers.
- graphQL is a typed language.
- Eg. Query Language
{
query { //operation : type
user{ //operation : endpoint
name //requested fields
age
}
}
}
- Query -- "for GET"
- Mutation -- "for POST/PUT/PATCH/DELETE"
- Subscription -- "setup realtime connection with sockets"
- Event booking API
- Event - Create, Update, Delete, View(Read)
- Users - Connected to events || Filters -- CreatedBy, Booked || BooksEvents, Cancel Booking
- npm install --save express body-parser
- npm install --save-dev nodemon
- npm install --save express-graphql graphql
- npm install --save mongoose
- npm install --save bcryptjs
- npm install --save jsonwebtoken
- prod -- node app.js
- dev -- npm start(uses nodemon)
- killall node
- if graphiql not working try on "http" instead of "https"
- Dates are passed via "new Date().toISOString()"
- remember to set CORS policy to server
By Yashwant