Giter Site home page Giter Site logo

basemax / first-nodejs-apollo-mongodb-graphql Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 0.0 1.36 MB

Good example for starter and learning GraphQL + Apollo Server + MongoDB + NodeJS easily and fastly. (based on Babel, Just in 10 minutes)

License: MIT License

JavaScript 100.00%
nodejs node-js graphql graphql-server graphql-client graphql-api graphql-schema graphql-examples graphql-example graphql-js

first-nodejs-apollo-mongodb-graphql's Introduction

First NodeJS Apollo MongoDB GraphQL

Good example for starter and learning GraphQL + Apollo Server + MongoDB + NodeJS easily and fastly. (Just in 10 minutes)

If you would like to read more, you can check out official documentation at here.

Features

  • MongoDB
  • GraphQL
  • ExpressJS
  • Apollo Server
  • Babel JS

Using

$ yarn install
$ yarn start

Then open http://localhost:4000/graphql/

Select all Cats

{
  cats {
     id
     name
  }
}

Mongodb - select all cats - Apollo GraphQL

Insert a new Model, Cat

mutation {
  createCat(name:"Max") {
    id
    name
  }
}

mongodb - insert a new model cat - Apollo GraphQL

Similar Repository

References

Did you encounter a problem in Babel?

The following link may be helpful: https://stackoverflow.com/a/51530314/10096230

Change "start": "nodemon --exec npm run babel-node index.js" to "start": "node ./node_modules/babel-cli/bin/babel-node.js --presets env index.js",

Installing Mongodb in Arch Linux

You can easily install MongoDB in Arch-base Linux by following commands:

pamac search -a mongodb-bin
pamac info -a mongodb-bin

And, then build and install with (this can be done after manually cloning too) -

pamac build mongodb-bin

Did you encounter a problem in MongoDB?

As shown below, the service does not run and has an error. This is a file access and execution error. The easiest way is as follows:

[max@base first-nodejs-apollo-graphql]$ sudo systemctl status mongodb
● mongodb.service - High-performance, schema-free document-oriented database
     Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Thu 2020-12-24 05:16:07 +0330; 4s ago

Modify /usr/lib/systemd/system/mongodb.service file. However, manipulating these accesses is not recommended.

Anyway, You can change user from mongodb to root to solve this problem:

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=root
ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf

[Install]
WantedBy=multi-user.target

And then:

$ systemctl daemon-reload

$ sudo systemctl restart mongodb

$ sudo systemctl status mongodb
● mongodb.service - High-performance, schema-free document-oriented database
     Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled; vendor preset: disabled)
     Active: active (running) since Thu 2020-12-24 05:16:39 +0330; 2s ago

$ sudo systemctl enable mongodb

Max Base

My nickname is Max, Programming language developer, Full-stack programmer. I love computer scientists, researchers, and compilers. (Max Base)

Asrez Team

A team includes some programmer, developer, designer, researcher(s) especially Max Base.

Asrez Team

first-nodejs-apollo-mongodb-graphql's People

Contributors

dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.