Minimal one-file GraphQL server built on pure Node.js, Connect, and graphql-js, with an embedded GraphiQL UI.
- Uses Connect as a lightweight middleware layer
- graphql-js as the execution engine
- No external body parsers or routers
- Easy to extend with auth, logging, or REST endpoints
- Install dependencies:
npm install
- Run the server:
npm run dev
- Open GraphiQL:
| Path | Method | Description |
|---|---|---|
/graphql |
POST | Main GraphQL endpoint |
/ |
GET | GraphiQL UI for interactive use |
{
hello
}
{
users {
id
name
email
}
}
{
user(id: "2") {
id
name
email
}
}
mutation {
sendMessage(message: "Hello world!") {
message
timestamp
}
}
curl -X POST http://localhost:8080/graphql \
-H "Content-Type: application/json" \
-d "{\"query\":\"{ hello }\"}"
curl -X POST http://localhost:8080/graphql \
-H "Content-Type: application/json" \
-d "{\"query\":\"{ users { id name email } }\"}"
curl -X POST http://localhost:8080/graphql \
-H "Content-Type: application/json" \
-d "{\"query\":\"{ user(id: \\\"2\\\") { id name email } }\"}"
curl -X POST http://localhost:8080/graphql \
-H "Content-Type: application/json" \
-d "{\"query\":\"mutation { sendMessage(message: \\\"Hello from curl\\\") { message timestamp } }\"}"
- GraphQL Queries:
hello,users,user(id: ID) - GraphQL Mutation:
sendMessage(message: String) - Interactive GraphiQL UI at
/ - Runs on pure Node.js HTTP with Connect middleware
- Fully written in TypeScript
- Fully deployable on Render.com
- Node.js >=22 – JavaScript runtime
- Connect 3.7 – Low-level middleware framework
- graphql 16.x – Official GraphQL execution engine
- GraphiQL – Embedded interactive IDE
- TypeScript – Strict typing and compile-time safety
- Render.com – Zero-config deployment