POST Queries & Mutations |
GET Queries only |
Use with online GraphQL tools, Postman, curl, etc.
Chapter I: The Injection
"Beyond the veil of queries lies a passage where shadows speak in database tongues. Those who master the ancient art of string concatenation may bend the data realm to their will, extracting secrets from tables unseen."
Chapter II: The Broken Access
"In the halls of the API, doors stand unlocked for all who seek. The internal chambers of user data lie bare to any traveler - no guardian questions those who walk the hidden corridors."
Chapter III: The Misplaced Trust
"The order bears the mark of its creator, yet any hand may seize it. When ownership goes unverified, the boundaries between yours and theirs dissolve into shadow."
Chapter IV: The Open Ledger
"Fields once forbidden now yield to the clever coder's touch. When all paths lead to the throne, when every attribute accepts the whisperer's will, true power transcends mere mortal constraints."
Chapter V: The Extending Reach
"Beyond the visible web lies a realm of machines and metadata. The curious can traverse the boundary between the public face and the hidden infrastructure that powers the kingdom."
Chapter VI: The Unwatched Treasury
"Crown jewels - order records, payment ledgers, system statistics - all lie within reach of the unguarded gate. The keepers have left their treasures unwatched, accessible to any who know where to look."
Chapter VII: The Skeleton Key
"A single key unlocks many doors, yet this key was forged from common words. The authentication bearer need only speak the secret phrase to command the realm's resources."
Available Coupon Codes
WELCOME10
10% Off
Welcome discount for new users
FLAT20
$20 Off
On orders over $100
SUMMER25
25% Off
Summer sale - orders over $50
DISCOUNT10
10% Off
General discount code
▶ Query Runner
Response will appear here...
🔒 Login
📝 Register
Quick Examples
# Query books (no auth)query { books(limit:5) { id title price } } # Get book by IDquery { book(id:1) { id title description author { firstName lastName } } } # Search booksquery { books(search:"code") { id title price } } # Loginmutation { login(username:"admin", password:"password123") { success token } } # Registermutation { register(username:"user", firstName:"John", lastName:"Doe", password:"pass") { success } } # Get current userquery { me { id username role firstName } } # Update profilemutation { updateProfile(phone:"1234567890", city:"NYC") { success } } # Add to cartmutation { addToCart(bookId:1, quantity:2) { success } } # View cartquery { cart { id items { bookId quantity } } } # Remove from cartmutation { removeFromCart(bookId:1) { success } } # Create ordermutation { createOrder { success orderId } } # View ordersquery { orders { id orderNumber status totalAmount } } # Cancel ordermutation { cancelOrder(orderId:"xxx") { success } } # Create reviewmutation { createReview(bookId:1, rating:5, comment:"Great!") { success } } # View reviewsquery { bookReviews(bookId:1) { id rating comment } } # Delete reviewmutation { deleteReview(reviewId:1) { success } } # Register webhookmutation { registerWebhook(url:"https://example.com", events:"order.created") { success } } # Test webhookmutation { testWebhook(webhookId:"xxx") { success } } # Advanced searchquery { _searchAdvanced(query:"python") { id title price } } # External resourcequery { _fetchExternalResource(url:"http://example.com") { content } }
Available Queries
QueryNo Auth
books
List books with filters
QueryNo Auth
book(id)
Get book details
QueryAuth
me
Get current user
QueryAuth
cart
Get shopping cart
QueryAuth
orders
Get order history
QueryNo Auth
_searchAdvanced
Advanced book search
QueryNo Auth
_internalUserSearch
Search users by username
QueryNo Auth
_fetchExternalResource
Fetch external URL content
Available Mutations
MutationNo Auth
register
Create account
MutationNo Auth
login
Get JWT token
MutationAuth
addToCart
Add to cart
MutationAuth
createOrder
Create order
MutationAuth
cancelOrder
Cancel order
MutationAuth
createReview
Add review
MutationAuth
deleteReview
Delete review
MutationAuth
updateProfile
Update user profile
MutationAuth
registerWebhook
Register webhook
MutationAuth
testWebhook
Test webhook endpoint
Features
📚
Book Catalog
🛒
Shopping Cart
📝
Reviews
🔗
Webhooks
🔒
JWT Auth
🢛
Orders
API Documentation
Complete guide to GraphQL Bookstore API
Welcome
Welcome to the GraphQL Bookstore API - a deliberately vulnerable API designed for security education and hands-on learning of GraphQL fundamentals. This project provides a realistic bookstore environment where you can explore common web vulnerabilities in a safe, educational setting.
What is This API?
The GraphQL Bookstore API simulates a real-world e-commerce platform built with GraphQL. It includes complete functionality for a bookstore including user accounts, book browsing, shopping cart, order management, product reviews, and webhook notifications. The API is intentionally built with various security vulnerabilities to help developers, security researchers, and students understand and identify common web application security flaws.
What is It Built For?
This API serves as a learning platform for:
Understanding GraphQL API security fundamentals
Learning to identify and exploit common vulnerabilities
Practicing secure coding techniques
Testing security tools and methodologies
Educational workshops and capture-the-flag (CTF) events
Business Flow
The API follows a typical e-commerce workflow:
1. USER REGISTRATION/LOGIN
└─→ Create account or authenticate to receive JWT token
2. BROWSE BOOKS
└─→ Query books, search by title/author/category
└─→ View book details and reviews
3. MANAGE CART
└─→ Add books to shopping cart
└─→ Update quantities or remove items
└──→ Apply coupon codes (discounts)
4. CHECKOUT & PAYMENT
└─→ Review cart contents
└─→ Process payment (simulated Vulnbank)
└─→ Create order record
5. ORDER MANAGEMENT
└─→ View order history
└─→ Cancel orders (if allowed)
└─→ Track order status
6. REVIEWS & RATINGS
└─→ Submit reviews for purchased books
└─→ View reviews from other users
7. WEBHOOKS (Optional)
└─→ Register webhook URLs for real-time notifications
└─→ Receive events: order created, paid, cancelled, etc.
The GraphQL Bookstore API accepts requests via HTTP POST to the /graphql endpoint. All requests must include a JSON body with a query field containing your GraphQL operation.
API Endpoints
You can use either of the following endpoints:
Local Development: http://localhost:4000/graphql
Live URL: https://api.graphqlbook.org/graphql
// All examples below use localhost. Simply replace with the live URL when ready.
Basic Request Structure
POST /graphql
Content-Type: application/json
{
"query": "Your GraphQL query or mutation here"
}
Using cURL
Query Books (No Auth Required)
curl -X POST http://localhost:4000/graphql \
-H "Content-Type: application/json" \
-d '{"query":"{ books { id title price } }"}'
Postman is a popular tool for testing APIs. Here's how to use it with this GraphQL API:
Method: POST
URL: http://localhost:4000/graphql
(or https://api.graphqlbook.org/graphql for production)
Headers:
Content-Type: application/json
Authorization: Bearer <your-token> // Only for authenticated requestsBody (JSON):
{
"query": "{ books { id title price } }"
}
Using Online Tools
You can also use online GraphQL tools like Apollo GraphQL Studio, Insomnia, or similar:
Apollo GraphQL Studio: https://studio.apollographql.com/sandbox/explore
Insomnia: https://insomnia.rest/download
Postman: https://www.postman.com/downloads
// Simply set the endpoint URL and send your GraphQL query
Ready-to-use Postman Collection
Import all queries and mutations into Postman with one click
The API uses JWT (JSON Web Tokens) for authentication. Here's the complete flow:
// Step 1: Login to get your JWT token
mutation {
login(username: "admin", password: "password123") {
success
token
user {
id
username
role
}
}
}
// Step 2: Use the token in subsequent requests
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
// Step 3: Token is valid for 6 hours. Include it in the
// Authorization header for protected endpoints
This section provides an overview of the GraphQL schema, including available data types and how to explore the API using introspection.
Main Data Types
The API defines several core types that represent the bookstore data model:
Book - Represents a book in the catalog
id, title, description, price, stockQuantity, categoryId, authorId
Author - Represents a book author
id, firstName, lastName, biography
User - Represents a registered user
id, username, email, role, firstName, lastName, phone, city
Order - Represents a customer order
id, orderNumber, userId, status, totalAmount, createdAt, items
OrderItem - Represents an item in an order
id, bookId, quantity, price
Cart - Represents a shopping cart
id, userId, items, subtotal, tax, discount, total
CartItem - Represents an item in the cart
id, bookId, quantity, price
Review - Represents a book review
id, bookId, userId, rating, comment, createdAt
Webhook - Represents a webhook subscription
id, userId, url, events, secret, isActive
Field Selection
GraphQL allows you to request only the specific fields you need. This reduces response size and improves performance.
Request All Fields
query {
books {
id
title
description
price
stockQuantity
author {
firstName
lastName
}
}
}
Request Only Specific Fields
query {
books {
id
title
price
}
}
Nested Field Selection
query {
cart {
id
items {
bookId
quantity
book {
title
price
}
}
}
}
GraphQL Introspection
GraphQL supports introspection, allowing you to query the schema itself to discover available types, fields, and operations.
query {
__type(name: "Book") {
name
kind
fields {
name
type {
name
kind
}
}
}
}
Query All Queries & Mutations
query {
__schema {
queryType { name }
mutationType { name }
subscriptionType { name }
}
}
Query Type Fields
query {
__schema {
queryType {
fields {
name
description
type {
name
}
args {
name
type {
name
}
}
}
}
}
}
Common Filters & Arguments
Many queries accept arguments to filter, sort, or limit results:
books(search: String, categoryId: Int, limit: Int)
- search: Filter by title or description
- categoryId: Filter by category
- limit: Limit number of results
book(id: Int!)
- id: Required - the book ID
_searchAdvanced(query: String!)
- query: Search query string
bookReviews(bookId: Int!)
- bookId: Required - filter reviews by book
The Bookstore API includes an MCP (Model Context Protocol) server that exposes all API operations as tools for AI and LLM models. This enables AI assistants to interact with the Bookstore API natively.
Quick Installation
# Navigate to MCP directory and install
cd mcp
npm install
Usage
Local Development:
# Start the Bookstore API server (from project root)
./bookstore-server
# In another terminal, start MCP server
cd mcp
npm start
Production (Live API):
cd mcp
API_URL=https://api.graphqlbook.org/graphql npm start
Available MCP Tools
The MCP server exposes 25 tools organized by category: