A simple CRUD API built with Express.js, TypeScript, GraphQL, and MongoDB, with a lightweight UI powered by Ruru HTML.
https://express-typescript-graphql.onrender.com/
- Backend: Express.js + TypeScript
- API: GraphQL
- Database: MongoDB (Mongoose)
- UI/Playground: Ruru (GraphQL HTML IDE)
- Manage Books and Authors with full CRUD operations.
- Query books and authors by ID or Name.
- Supports adding, updating, and deleting data.
- Simple UI with Ruru HTML for testing queries and mutations.
Install this app with npm
-
Clone the repository:
git clone https://github.com/Seyam08/express-typeScript-graphql.git
-
Make sure MongoDB is running locally or provide a connection string in .env:
MONGO_CONNECTION_STRING="mongodb://localhost:27017/graphql"
-
Install the dependencies:
npm install
-
Start the application:
Development version
npm run dev
-
Build
npm run build
-
Run the Production server
npm start
-
Open the package.json file to see all the scripts.
query {
allBooks {
id
name
author {
id
name
}
}
allAuthors {
id
name
}
}
query {
authorById(id: "68e20964a7ad53a") {
id
name
}
bookById(id: "68e2096d3da7ad53a") {
id
name
author {
id
name
}
}
}
query {
authorByName(name: "Elif Shafak") {
id
name
}
booksByName(name: "The Forty Rules of Love") {
id
name
author {
id
name
}
}
}
mutation {
addAuthor(name: "Elif Shafak") {
id
name
}
}
mutation {
addBook(authorName: "Elif Shafak", name: "The Forty Rules of Love") {
id
name
author {
id
name
}
}
}
mutation {
updateAuthor(id: "68e2096d3d64c6f53a", newName: "Elif Shafak") {
id
name
}
}
mutation MyMutation {
updateBook(id: "68e2096d3d64c6f53a", newName: "The Forty Rules of Love") {
id
name
author {
id
name
}
}
}
mutation {
deleteBook(id: "68e2096d3d642c6f53a") {
id
name
}
}
- All queries and mutations can be tested using Ruru HTML UI or tools like Postman / Insomnia.
- Make sure MongoDB is running before executing queries.