Skip to content

ankurksoni/node-mongo-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-mongo-graphql

A Nodejs app with express.js, graphql, mongodb, mongoose etc.

Pre-requisites

  • Make sure you have latest Node.js installed
  • Make sure you have docker engine installed

Local setup

  • 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 ps

    node-mongo-graphql_mongo_1 is up-to-date
    Recreating node-mongo-graphql_node-graphql_1 ... done

GraphQL queries

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
        }
      }
    }

About

A Nodejs app with express.js, graphql, mongodb, etc.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published