https://github.com/basemax/first-nodejs-graphql
Good example for starter and learning GraphQL + NodeJS easily and fastly. (Just in 10 minutes)
https://github.com/basemax/first-nodejs-graphql
express express-js expressjs expressjs-server graphql graphql-api graphql-example graphql-examples graphql-js graphql-nodejs graphql-schema graphql-server js node-js nodejs
Last synced: 3 months ago
JSON representation
Good example for starter and learning GraphQL + NodeJS easily and fastly. (Just in 10 minutes)
- Host: GitHub
- URL: https://github.com/basemax/first-nodejs-graphql
- Owner: BaseMax
- License: mit
- Created: 2020-12-24T00:35:33.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-01-17T11:07:18.000Z (4 months ago)
- Last Synced: 2025-02-04T07:15:40.435Z (4 months ago)
- Topics: express, express-js, expressjs, expressjs-server, graphql, graphql-api, graphql-example, graphql-examples, graphql-js, graphql-nodejs, graphql-schema, graphql-server, js, node-js, nodejs
- Language: JavaScript
- Homepage:
- Size: 1.93 MB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# First NodeJS GraphQL
Good example for starter and learning GraphQL + NodeJS easily and fastly. (Just in 10 minutes)
If you would like to read more, you can check out official documentation at [here](https://graphql.org/graphql-js/running-an-express-graphql-server/).
## Using
```
$ yarn install
$ yarn start
```- Download MongoDB Compass and install from [here](https://www.mongodb.com/try/download/compass).
Once MongoDB Compass is installed, you can open it to view your host and port details.
- Make sure to update your database configuration in `config/.env` to match your MongoDB setup.
## images of MongoCompass
- Below are some images showcasing MongoDB Compass to help you get familiar with the interface.



Then open: `http://localhost:5000/graphql/?query=%7B%0A%20%20books%20%7B%0A%20%20%20%20id%2C%0A%20%20%20%20name%0A%20%20%7D%0A%0A%7D`
## Examples
#### List of all books id and name
```
{
books {
id,
name
}
}
```
#### List of authors and their books
```
{
authors {
id
name
books {
name
}
}
}
```
#### List of authors name
```
{
authors {
name
}
}
```
#### List of books id
```graphql
{
books {
id
}
}
```
#### Get a Single Book by args(Id)
```graphql
{
book(id:"66fdc7ab769dea390bb26fc8") {
name
}
}
```
#### Add book by name and authorId
```graphql
{
mutation{
addBook(name:"sincefiction",authorId:"66fdc6e7769dea390bb26fc4"){
id,
name
}
}
}
```
#### Add author by name
```graphql
{
mutation{
addAuthor(name:"max"){
id,
name
}
}
}
```
## Similar Repository
- https://github.com/BaseMax/first-nodejs-apollo-graphql/
### References
- https://graphql.org/graphql-js/running-an-express-graphql-server
- https://github.com/graphql/express-graphql
- https://www.youtube.com/watch?v=n1mdAPFq2Os
- https://www.youtube.com/watch?v=YBydg_Ui02Q
- https://www.youtube.com/watch?v=ZQL7tL2S0oQ---------
# Max Base
My nickname is Max, Programming language developer, Full-stack programmer. I love computer scientists, researchers, and compilers. ([Max Base](https://maxbase.org/))
## Asrez Team
A team includes some programmer, developer, designer, researcher(s) especially Max Base.
[Asrez Team](https://www.asrez.com/)