Relay-compliant GraphQL server using TypeGraphQL and TypeORM boilerplate.
This documentation will be completely rewritten explaining better how to get started. This means that this repository is constantly changing and that is why we don't recommend using it in production until all features have been completed.
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
type
on the database loader and remove thepg
package.
If you have Docker and Docker Compose installed you just need to run docker-compose up -d
on your terminal.
The
postgres
service will create automatically the dabatase specified on theDATABASE_NAME
environment 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_PATH
environment variable.
The most important parts are implemented and working properly but we have room for improvements.
- Tests
- Ordering
- Filtering
- Error handling
- DataLoader
- Production ready
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
}
}
}