The gateway API is built with NestJS and Graphql.
pnpm: Fast, disk space efficient package manager.
npm install -g pnpm
Setting up a new project is quite simple with the Nest CLI.
npm i -g @nestjs/cli
$ nest new
pnpm install
pnpm run start:dev
# Adding users and posts
nest g app
# Adding graphql (first code) in users app
nest g resource
pnpm i @apollo/gateway @apollo/subgraph @nestjs/graphql @nestjs/apollo @apollo/server graphql
# run users' graphql
pnpm start:dev users
url: http://localhost:3000/graphql users'qraphql example:
mutation{
createUser(createUserInput:{id:"123",email:"test@gmail.com",password:"pass123"}){
id
email
password
}
}
query{
user(id:"123"){
id
email
password
}
query{
posts{
id
authorId
user{
id
email
password
}
}
}
}
query{
users{
id
email
password
posts{
id
body
authorId
}
}
}
# HTTP HEADERS
{
"Authorization":"123"
}