Suppose you have two tables in your database
- Feed
- User
Feed Array
"feed": [
{
"id": 1,
"full_name": "Ainslee Giffard",
"user_name": "agiffard0",
"user_avatar": "https://robohash.org/architectoetveniam.png",
"image_url": "http://dummyimage.com/234x245.png",
"likes": [{ "id": 107 }, { "id": 20 }, { "id": 79 }, { "id": 159 }],
},
.
.
.
]
User Array
"users": [
{
"user_id": 1,
"full_name": "Ankit Dhawan",
"user_name": "adhawan",
"user_avatar": "https://robohash.org/sapienteplaceatet.png",
},
.
.
.
]
Query
query {
getFeed {
likes {
id
}
}
}
Output 👇🏻
{
"data": {
"getFeed": [
{
"likes": [
{"id":107},{"id":20},{"id":79},{"id":159}
]
}
]
}
}
Query
query {
getUser(id: 107) {
full_name
user_name
}
}
Output 👇🏻
{
"data": {
"getUser": [
{
"full_name": "Ankit Dhawan",
"useranme": "adhawan"
}
]
}
}
GraphQL Shield provides a straightforward approach to writing permissions in GraphQL servers. Its primary focus is abstracting permission layer efficiently from the logic layer of our server. Nevertheless, its raw power comes with dynamic caching which significantly reduces server load and accounts for faster query evaluation.
You can read more about GraphQL Shield here
bcrypt is a password hashing function which uses a 128-bit salt and encrypts a 192-bit magic value. It takes advantage of the expensive key setup in eksblowfish.
You can read more about Bcrypt here
Command | Description |
---|---|
git clone |
Clone an existing repo to your device |
npm install |
Install all the required dependencies for project |
npm start |
Run the project |
npm run devStart |
Run the project with nodemon |
- express-graphql
- express
- graphql
- nodemon (optional)
- graphql-shield
- graphql-middleware
- bcrypt
You can know more about Graph QL here
Check out Graph QL Express Documentation here