graphQL Server with Mongo DB (Mongoose), Node JS and Express JS
1. git clone https://github.com/akinmaurice/graphql-server.git
2. cd graphql-server
3. npm install
4. Add MongoDB connection String to .envSample file
5. Rename .envSample file to .env
6. npm start
The above will get you a copy of the project up and running on your local machine for development and testing purposes.
query {
Users {
email
name
}
}
{
"data": {
"Users": [
{
"email": "akin@gmail.com",
"name": "Akintayo Akinyemi"
},
{
"email": "akinyemi@gmail.com",
"name": "Akin Maurice"
},
{
"email": "akingithub@gmail.com",
"name": "John Doe"
}
]
}
}
query{
User(id: "5a5667d0763358725e13a65c") {
email
name
posts {
title
content
}
}
}
{
"data": {
"User": {
"email": "akinyemi@gmail.com",
"name": "John Doe",
"posts": [
{
"title": "Sample POst Test",
"content": "Sample Post Content"
},
{
"title": "Sample Post Test 2",
"content": "Sample Post Contgigbgkgent"
}
]
}
}
}
mutation{
AddUser(data: {
email: "akingithub@gmail.com",
name: "John Doe"
})
}
{
"data": {
"AddUser": {
"email": "akingithub@gmail.com",
"name": "John Doe"
}
}
}
mutation {
UpdateUser(
id: "5a5667d0763358725e13a65c",
data: {
name: "Akin Maurice"
}
)
}
{
"data": {
"UpdateUser": {
"email": "akinyemi@gmail.com",
"name": "Akin Maurice"
}
}
}
mutation {
DeleteUser (id: "5a5667d0763358725e13a65c")
}
{
"data": {
"DeleteUser": {
"email": "akinyemi@gmail.com",
"name": "Akin Maurice"
}
}
}
mutation {
Addpost (data: {
author: "5a5667d0763358725e13a65c",
title: "Sample Post Test 2",
content: "Sample Post Contgigbgkgent"
})
}
{
{
"data": {
"Addpost": {
"author": "5a5667d0763358725e13a65c",
"title": "Sample Post Test",
"content": "Sample Post Confhgjhghtgigbgkgent"
}
}
}
}
query {
# List All Posts
Posts {
title
content
comments {
email
name
comment
}
}
}
{
"data": {
"Posts": [
{
"title": "Sample Post Test",
"content": "Sample Post Content",
"comments": [
{
"email": "akinyemi@gmai.com",
"name": "Akintayo Akinyemi",
"comment": "First Comment For the Post"
}
]
},
{
"title": "Sample Post Test 2",
"content": "Sample Post Contgigbgkgent",
"comments": []
}
]
}
}
query {
# List All Posts
Post(id: "5a56a3b9c119431217a372e9") {
title
content
comments {
email
name
comment
}
}
}
{
"data": {
"Post": [
{
"title": "Sample Post Test",
"content": "Sample Post Content",
"comments": [
{
"email": "akinyemi@gmai.com",
"name": "Akintayo Akinyemi",
"comment": "First Comment For the Post"
}
]
}
]
}
}
mutation {
Addcomment (data: {
article: "5a56a3b9c119431217a372e9",
name: "Akintayo Akinyemi",
email: "akinyemi@gmai.com",
comment: "First Comment For the Post"
})
}
{
"data": {
"Addcomment": {
"article": "5a56a3b9c119431217a372e9",
"email": "akinyemi@gmai.com",
"name": "Akintayo Akinyemi",
"comment": "First Comment For the Post"
}
}
}
- GraphQL
- MongoDB with Mongoose
- Node JS
- Express JS
- Babel
This project is licensed under the MIT License - see the LICENSE.md file for details