https://github.com/dinushchathurya/nodejs-graphql
Simple NodeJS & GraphQL API
https://github.com/dinushchathurya/nodejs-graphql
express express-graphql graphql graphql-express-nodejs mongo mongoose nodejs nodejs-graphql
Last synced: 9 months ago
JSON representation
Simple NodeJS & GraphQL API
- Host: GitHub
- URL: https://github.com/dinushchathurya/nodejs-graphql
- Owner: dinushchathurya
- Created: 2022-06-11T02:58:13.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-14T10:57:34.000Z (almost 4 years ago)
- Last Synced: 2025-07-18T17:43:38.690Z (9 months ago)
- Topics: express, express-graphql, graphql, graphql-express-nodejs, mongo, mongoose, nodejs, nodejs-graphql
- Language: JavaScript
- Homepage:
- Size: 67.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Simple NodeJS GraphQL API with ExpressJS and MongoDB
### Install backend dependencies
```
npm install
```
### Add Mongo URI
If you're going to use MongoDB, create a database with Atlas, add it to the .env.example file and rename the file to .env
### Run Application
```
npm run dev
```
Then navigate to http://localhost:5000/graphql
### Queries & Mutations
#### Get all clients
```
{
clients {
name
}
}
```
#### Get client by id
```
{
client(id: 1) {
name
email
}
}
```
#### Get a single project name, description along with the client name and email
```
{
project(id: 1) {
name
description,
client {
name
email
}
}
}
```
#### Create a new client and return all data
```
mutation {
addClient(name: "John Doe", email: "johndoe@gmail.com", phone: "789-745-712") {
id
name
email
phone
}
}
```
#### Delete a client and return id
```
mutation {
deleteClient(id: 1) {
id
}
}
```
#### Create a new project and return name and description
```
mutation {
addProject(name: "Sample Project", description: "This is the project description", status: "new", clientId: "1") {
name
description
}
}
```
#### Update a project status and return name and status
```
mutation {
updateProject(status: "completed") {
name
status
}
}
```