This project demonstrates how to create a powerful and efficient GraphQL API using PostgreSQL and the PostGraphile extension. PostGraphile automatically generates a fully-featured GraphQL API from your PostgreSQL database schema.
- Auto-Generated Schema: Instantly get a full CRUD GraphQL API based on your PostgreSQL schema.
- Real-time Updates: Subscribe to changes in your database and get real-time updates.
- Custom Business Logic: Embed business logic directly in your database with PL/pgSQL functions.
- Efficient Data Fetching: PostGraphile generates efficient SQL queries, minimizing the number of database hits.
Before you begin, ensure you have met the following requirements:
- Node.js and npm installed.
- Access to a PostgreSQL database.
- Basic knowledge of GraphQL and PostgreSQL.
To get a local copy up and running, follow these steps:
- Install PostGraphile Globally:
npm install -g postgraphile
- Run a PostgreSQL instance:
You can use Docker and Docker-compose if you want
docker-compose up --build
- Usage
This command will start the GraphQL API
yarn start:dev
or
npm run start:dev
and it will be available at the Playground http://localhost:5000/graphiql
query {
allUsers {
nodes {
id
name
email
}
}
}
or a mutation
mutation {
createUser(input: {user: {name: "John Doe", email: "john.doe@example.com"}}) {
user {
id
name
email
}
}
}