{
  "info": {
    "name": "GraphQL Bookstore API",
    "description": "A GraphQL API for a bookstore with authentication, shopping cart, orders, reviews, and webhooks.\n\n## User Flow\n1. Register/Login → Get token\n2. Browse books → Search → View details\n3. Add items to cart → Apply coupon\n4. Checkout → Payment → Order created\n5. View orders → Cancel if needed\n6. Create reviews for purchased books\n\n## Setup\n1. Import this collection into Postman\n2. Set the `base_url` variable (default: http://localhost:4000) or use (live URL: https://api.graphqlbook.org)\n3. Fill in the input variables before each request\n4. Use the Login mutation to get a token, then set the `token` variable\n\n## Input Variables\n- `username` - Login username\n- `password` - Login password\n- `firstName` - First name for registration/profile\n- `lastName` - Last name for registration/profile\n- `bookId` - Book ID for cart/review operations\n- `quantity` - Quantity for cart operations\n- `couponCode` - Coupon code (WELCOME10, FLAT20, SUMMER25, DISCOUNT10)\n- `rating` - Rating for reviews (1-5)\n- `comment` - Comment text for reviews\n- `reviewId` - Review ID for deletion\n- `webhookId` - Webhook ID for testing\n- `webhookUrl` - URL for webhook registration\n- `orderId` - Order ID for cancellation\n- `cardNumber` - Payment card number (any 13-19 digits)\n- `cardExpiry` - Card expiry (MM/YY)\n- `cardCvv` - Card CVV (3-4 digits)\n\n## Default Credentials\n- admin / password123 (admin)\n- staff / password123 (staff)\n- user / password123 (user)",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "http://localhost:4000",
      "type": "string"
    },
    {
      "key": "token",
      "value": "",
      "type": "string"
    },
    {
      "key": "username",
      "value": "",
      "type": "string"
    },
    {
      "key": "password",
      "value": "",
      "type": "string"
    },
    {
      "key": "firstName",
      "value": "",
      "type": "string"
    },
    {
      "key": "lastName",
      "value": "",
      "type": "string"
    },
    {
      "key": "bookId",
      "value": "",
      "type": "string"
    },
    {
      "key": "quantity",
      "value": "1",
      "type": "string"
    },
    {
      "key": "couponCode",
      "value": "WELCOME10",
      "type": "string"
    },
    {
      "key": "rating",
      "value": "5",
      "type": "string"
    },
    {
      "key": "comment",
      "value": "Great book!",
      "type": "string"
    },
    {
      "key": "reviewId",
      "value": "",
      "type": "string"
    },
    {
      "key": "webhookId",
      "value": "",
      "type": "string"
    },
    {
      "key": "webhookUrl",
      "value": "http://example.com/webhook",
      "type": "string"
    },
    {
      "key": "orderId",
      "value": "",
      "type": "string"
    },
    {
      "key": "cardNumber",
      "value": "4111111111111111",
      "type": "string"
    },
    {
      "key": "cardExpiry",
      "value": "12/25",
      "type": "string"
    },
    {
      "key": "cardCvv",
      "value": "123",
      "type": "string"
    },
    {
      "key": "search",
      "value": "",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "1. Authentication",
      "item": [
        {
          "name": "Register",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"mutation { register(username: \\\"{{username}}\\\", firstName: \\\"{{firstName}}\\\", lastName: \\\"{{lastName}}\\\", password: \\\"{{password}}\\\") { success message } }\"}"
            }
          }
        },
        {
          "name": "Login",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"mutation { login(username: \\\"{{username}}\\\", password: \\\"{{password}}\\\") { success token user { id username role } } }\"}"
            }
          }
        }
      ]
    },
    {
      "name": "2. Browse Books",
      "item": [
        {
          "name": "Books (All)",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"{ books { id title author { firstName lastName } price stockQuantity category { name } } }\"}"
            }
          }
        },
        {
          "name": "Book (By ID)",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"{ book(id: {{bookId}}) { id title author { firstName lastName } price description stockQuantity category { name } } }\"}"
            }
          }
        },
        {
          "name": "Books (Search)",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"{ books(search: \\\"{{search}}\\\") { id title author { firstName } price } }\"}"
            }
          }
        },
        {
          "name": "Book Reviews",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"{ bookReviews(bookId: {{bookId}}) { id rating comment user { username } createdAt } }\"}"
            }
          }
        }
      ]
    },
    {
      "name": "3. User Profile",
      "item": [
        {
          "name": "Me (Current User)",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"{ me { id username firstName lastName role } }\"}"
            }
          }
        },
        {
          "name": "Update Profile",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"mutation { updateProfile(firstName: \\\"{{firstName}}\\\", lastName: \\\"{{lastName}}\\\") { success message } }\"}"
            }
          }
        }
      ]
    },
    {
      "name": "4. Shopping Cart",
      "item": [
        {
          "name": "View Cart",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"{ cart { id items { id book { id title price } quantity } subtotal tax discount couponCode total } }\"}"
            }
          }
        },
        {
          "name": "Add to Cart",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"mutation { addToCart(bookId: {{bookId}}, quantity: {{quantity}}) { success message } }\"}"
            }
          }
        },
        {
          "name": "Remove from Cart",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"mutation { removeFromCart(bookId: {{bookId}}) { success message } }\"}"
            }
          }
        },
        {
          "name": "Apply Coupon",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"mutation { applyCoupon(code: \\\"{{couponCode}}\\\") { success message discount } }\"}"
            }
          }
        }
      ]
    },
    {
      "name": "5. Checkout & Orders",
      "item": [
        {
          "name": "Create Order (No Payment)",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"mutation { createOrder { success orderId totalAmount } }\"}"
            }
          }
        },
        {
          "name": "Checkout (With Payment)",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"mutation { checkout(cardNumber: \\\"{{cardNumber}}\\\", expiry: \\\"{{cardExpiry}}\\\", cvv: \\\"{{cardCvv}}\\\") { success orderId orderNumber totalAmount warning payment { success message transactionId } } }\"}"
            }
          }
        },
        {
          "name": "View Orders",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"{ orders { id orderNumber status totalAmount paymentStatus createdAt items { id book { id title } quantity unitPrice } } }\"}"
            }
          }
        },
        {
          "name": "Cancel Order",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"mutation { cancelOrder(orderId: \\\"{{orderId}}\\\") { success message } }\"}"
            }
          }
        }
      ]
    },
    {
      "name": "6. Reviews",
      "item": [
        {
          "name": "Create Review",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"mutation { createReview(bookId: {{bookId}}, rating: {{rating}}, comment: \\\"{{comment}}\\\") { success message } }\"}"
            }
          }
        },
        {
          "name": "My Reviews",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"{ myReviews { id rating comment book { id title } createdAt } }\"}"
            }
          }
        },
        {
          "name": "Delete Review",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"mutation { deleteReview(reviewId: {{reviewId}}) { success message } }\"}"
            }
          }
        }
      ]
    },
    {
      "name": "7. Webhooks",
      "item": [
        {
          "name": "Register Webhook",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"mutation { registerWebhook(url: \\\"{{webhookUrl}}\\\", events: [\\\"order.created\\\", \\\"order.paid\\\", \\\"order.cancelled\\\"], secret: \\\"mysecret\\\") { success message webhook { id } } }\"}"
            }
          }
        },
        {
          "name": "View Webhooks",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"{ webhooks { id url events isActive createdAt } }\"}"
            }
          }
        },
        {
          "name": "Test Webhook",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/graphql",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"query\":\"mutation { testWebhook(webhookId: \\\"{{webhookId}}\\\") { success message } }\"}"
            }
          }
        }
      ]
    }
  ]
}
