A Nodejs app with express.js, graphql, mongodb, mongoose etc.
- Make sure you have latest Node.js installed
- Make sure you have docker engine installed
-
Ensure you have checkout fom master code.
-
goto to the project folder and run command
docker-compose down node-jwt;docker rmi $(docker images -f "dangling=true" -q); docker system prune; docker-compose up --build -d -
you must see mongodb and our server container up and running with command
docker psnode-mongo-graphql_mongo_1 is up-to-date Recreating node-mongo-graphql_node-graphql_1 ... done
Goto http://localhost:3000/graphql, you must see graphiql UI interface ready for you. Test below queries by copy pasting command on the LHS of the UI interface.
-
For doing any kind of mutation, [Note: Use appropriate
authorId]mutation { addAuthor(name: "book2", age: 33){ name age id } } mutation { addBook(name: "book2", genre: "genre2", authorId: "646358f87ad8d02d4d0a0d63"){ name genre id } } -
For doing retrieval of book information,
{ books{ name genre author{ name age } } } -
For doing retrieval of author information,
{ authors{ name age books{ name genre } } } -
For doing retrieval of a specific book. [Note: Use appropriate
id]{ book(id: "64635cbc17c53c651540b687") { name genre author{ name age } } } -
For doing retrieval of a specific author. [Note: Use appropriate
id]{ author(id: "646358f87ad8d02d4d0a0d63") { name age books{ name genre } } }