Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/matheustanaka/challengeGraphql

CRUD using Graphql, Apollo server and Mongodb.
https://github.com/matheustanaka/challengeGraphql

apollo-server database graphql mongodb nodejs

Last synced: 8 days ago
JSON representation

CRUD using Graphql, Apollo server and Mongodb.

Awesome Lists containing this project

README

        

# Challenge Graphql

CRUD using graphql, apollo server and mongodb.

## Getting Started

---

# MongoDB
- You have to create a database or just use your database in Docker (only MongoDB).

# install dependencies
$ yarn install

# start project
$ yarn dev

# see graphql interface on localhost link
http://localhost:4001/graphql

## Queries

---

- Create User

mutation {
createUser(data: {
firstName: "Matheus",
lastName: "Tanaka",
email: " [email protected]"
active: true
}) {
_id
firstName
lastName
email
}
}

- Query User

query {
users {
_id
firstName
lastName
fullName
email
active
}
}

- Delete User

mutation{
deleteUser(id: "60b9753dcf587036e0008644")
}

- Update User

mutation {
updateUser (id: "60b9753dcf587036e0008644", data: {
firstName: "Matheus3333",
lastName: "Tanaka",
email: "[email protected]"
active: true
}) {
_id
firstName
lastName
email
}
}

* Create Post

mutation {
createPost(data:{
title: "Testing 2 other poster",
content: "testing",
author: "60b9753dcf587036e0008644"
}) {
_id
title
content
author{
fullName
_id
}
}
}

* Query Post

query {
posts {
_id
title
content
author {
fullName
}
}
}

* Delete Post

mutation {
deletePost(id: "60b97f8694a07035382d075d")
}

* Update Post

mutation {
updatePost(id: "60b97ff238ad2b1444c36f97", data:{
title: "Updating my second post",
content: "testing",
author: "60b9753dcf587036e0008644"
}) {
_id
title
content
author{
_id
fullName
}
}
}