Relay-compliant GraphQL server using TypeGraphQL and TypeORM boilerplate.
This is a GraphQL server boilerplate that follows the Global Object Identification, GraphQL Server Specification and GraphQL Cursor Connections Specification specifications.
You need to configure the environment variables. Just create a .env based on .env.defaults.
This boilerplate requires that you have a PostgreSQL instance running, you can either install on your operating system or use Docker instead.
In order to change from PostgreSQL to another TypeORM supported database (MySQL, MariaDB, SQL Server, etc) you just need to change the
typeon the database loader and remove thepgpackage.
If you have Docker and Docker Compose installed you just need to run docker-compose up -d on your terminal.
The
postgresservice will create automatically the dabatase specified on theDATABASE_NAMEenvironment variable.
Install all the dependencies
yarn
Then you can finally
yarn start:dev
If you see this message on your terminal:
✔ The server is running at http://127.0.0.1:8080
Congratulations, the server is running. 🚀
The GraphQL endpoint is based on the
GRAPHQL_PATHenvironment variable.
The most important parts are implemented and working properly but we have room for improvements.
- Ordering
- Filtering
- Custom arguments example
- Error handling
- DataLoader
Feel free to send suggestions and pull requests.
mutation {
addProduct(
input: {
name: "iPhone 12 Pro"
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi sed dui scelerisque, lacinia ipsum vitae, placerat felis."
}
) {
product {
id
name
description
createdAt
updatedAt
}
}
}{
node(id: "UHJvZHVjdDoy") {
... on Product {
id
name
description
createdAt
updatedAt
}
}
nodes(ids: ["UHJvZHVjdDoy"]) {
... on Product {
id
name
description
createdAt
updatedAt
}
}
}Forward
{
products(first: 2) {
edges {
node {
id
name
description
createdAt
updatedAt
}
cursor
}
pageInfo {
startCursor
endCursor
hasPreviousPage
hasNextPage
}
}
}Forward with cursor
{
products(first: 2, after: "YXJyYXljb25uZWN0aW9uOjE=") {
edges {
node {
id
name
description
createdAt
updatedAt
}
cursor
}
pageInfo {
startCursor
endCursor
hasPreviousPage
hasNextPage
}
}
}Backward
{
products(last: 2) {
edges {
node {
id
name
description
createdAt
updatedAt
}
cursor
}
pageInfo {
startCursor
endCursor
hasPreviousPage
hasNextPage
}
}
}Backward with cursor
{
products(last: 2, before: "YXJyYXljb25uZWN0aW9uOjg=") {
edges {
node {
id
name
description
createdAt
updatedAt
}
cursor
}
pageInfo {
startCursor
endCursor
hasPreviousPage
hasNextPage
}
}
}