Node.js/Express CRUD backend using GraphQL and JSON-Server
0.0.1
$ npm install
$ npm run json:server
$ npm run dev:server
Go to http://localhost:4000/graphql
- Retrieve all the customers
{
customers {
id,
name,
email,
age
}
}
- Find a specific customer by id and retrieve your name and email
{
customer(id: "2") {
name,
email
}
}
- Delete a customer by id and retriever the email field (null)
mutation {
deleteCustomer(id: "29") {
email
}
}
- Edits an existent customer by id and retriever your id and name fields
mutation {
editCustomer(id: "1", name: "Breno Henrique") {
id,
name
}
}
- Find a customer by id and retrieve your name and your purchases
{
customer(id: "1") {
name
purchases {
id,
product_id,
total_spent
}
}
}