Simple introduction of GraphQL where mutations are implemented in one of the attribute i.e. users
- Make directory for the application
- Go to the location of directory
- Then in your cmd or vscode terminal, run npm init command
- After that there will asking some couple of questions, we don't require to answer that so keep on hitting Enter key.
- Now, next is installing dependencies below:
-
Intalling express, express-graphql, graphql and lodash for that enter: npm install --save express express-graphql graphql lodash
-
Install json-server, enter command: npm install --save json-server
-
Install axios, enter command: npm install --save axios
-
Install nodemon for dynamic running our server enter command: npm install --save nodemon
Make some couple of changes in your package.JSON as like the changes made in the file you see there for running our servers. Create the json file as like there db.json for data storage.
For GraphQL operation in browser after you run server in terminal, its always better to go through the documentation and check out the process for generating data and mutating.
It is required to run servers i.e json-server and graphql, before to see some actions so for that use command below:
- For json-server: npm run json:server
- For graphql: node server.js