Skip to content

brenohq/graphql-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphql-server

Node.js/Express CRUD backend using GraphQL and JSON-Server

Version

0.0.1

Usage

First, Install Dependencies

$ npm install

Run JSON-Server (Port 3000)

$ npm run json:server

Run Server (Port 4000)

$ npm run dev:server

Visit Graphiql IDE

Go to http://localhost:4000/graphql

Query examples to reproduce

  • 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
    }
  }
}

About

GraphQL server using Express and JSON-Server

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published