This is very simple express server ready to use with the integration of graphql.
Clone repository
git clone https://github.com/Rohitturbot/express-graphql.git
go to
cd ./express-graphql
install dependencies
npm i
run project
npm run start
It runs on PORT number 8080
so you have to navigate to the localhost:8080/graphql
to use it. You can run GraphQL queries in the GraphiQL client provided by GraphQL developers.
This have two GraphQL types UserType
& PostType
. We have Quires & Mutation builtin to test.
I'm using JSONPlaceholder as my datastore. so you can make use of it.
- Get User with specific ID
user(id:"10"){
phone
id
name
username
}
- Get Post of Specific ID
post(id:"2"){
id
body
user{
id
name
}
}
- Add User to the DataStore(DB)
mutation{
addUser(name:"lalit"){
id
name
phone
}
}
- Update/Edit User to the DataStore(DB)
mutation{
updateUser(id:"10", phone:"8765522803"){
phone
id
name
}
}
- Delete User to the DataStore(DB)
mutation{
delete(id:"10"){
id
}
}