@dumbql/dev-server
v1.0.5
Published
Unified development server for DumbQL — mock GraphQL backend + frontend proxy, no CORS hassle
Maintainers
Readme
@dumbql/dev-server
Unified development server for DumbQL — serves a mock GraphQL backend and proxies all other requests to your frontend dev server. No CORS, no separate terminals, no hassle.
Install
npm install @dumbql/dev-serverUsage
CLI
dumbql-dev --proxy http://localhost:4200This starts a server on port 4000 that:
- Serves a mock GraphQL API at
http://localhost:4000/graphql - Proxies all other requests to
http://localhost:4200(your frontend)
Configuration via dumbql.config.json
{
"mock": {
"schema": "type Query { getNotes: [Note!]! } type Note { id: ID! title: String! content: String! }"
},
"proxy": {
"target": "http://localhost:5173"
}
}With Schema + Resolvers
dumbql-dev --schema ./graphql/schema.graphql --resolvers ./mock/resolvers.jsProgrammatic API
import { createDevServer, startDevServer } from '@dumbql/dev-server';
const server = createDevServer({
mock: {
schema: 'type Query { ping: String }',
resolvers: { Query: { ping: () => 'pong' } },
},
proxy: { target: 'http://localhost:4200' },
});
startDevServer({ port: 4000 });API
| Export | Description |
| -------------------------- | ---------------------------------------------------- |
| createDevServer(config?) | Creates a Node.js http.Server with GraphQL + proxy |
| startDevServer(config?) | Creates and starts the server on the given port |
CLI Options
| Flag | Default | Description |
| ------------- | ------------------------ | ----------------------- |
| --port | 4000 | Server port |
| --proxy | http://localhost:4200 | Frontend dev server URL |
| --schema | graphql/schema.graphql | Path to schema file |
| --resolvers | mock/resolvers.js | Path to resolvers file |
| --config | dumbql.config.json | Path to config file |
Dependencies
graphql, graphql-yoga
