Skip to content
MeshQL

MeshQL

Shape your API, not your codebase.
TypeScriptRESTSQL-nativeJSRnpm

MeshQL adds GraphQL-style field selection to REST. Clients ask for exactly what they need. You write one SQL query, return flat rows, and MeshQL shapes nested JSON — no resolver per field.

The idea

GraphQL pain

40 resolvers, N+1 debugging, and codegen eating your types.

REST pain

Every client wants a different ?include= and you ship half the database.

MeshQL middle ground

Normal REST URLs. Query in headers. One resolver per entity. SQL you already write.

Get started in minutes

Published on JSR (@meshql/*) andnpm (meshql-*).

npm
npm install meshql-core meshql-http meshql-client
npm i express
JSR
npx jsr add @meshql/core @meshql/http @meshql/client
npm i express

No database required for the first run — follow the5-minute guide or try theinteractive showcase.

Client query → nested JSON
// X-Mesh-Query (base64 JSON)
{
  "user": {
    "id": true,
    "name": true,
    "tokens": { "accessToken": true }
  }
}
// Response
{
  "user": {
    "id": 1,
    "name": "Ada Lovelace",
    "tokens": [{ "accessToken": "tok_ada" }]
  }
}

How it works

  1. 1

    Define a schema

    Entities, fields, joins — one resolver per root entity.

  2. 2

    Client sends a query

    JSON or QL in X-Mesh-Query. The SDK encodes it for you.

  3. 3

    MeshQL shapes the response

    JoinPlan tells you what to fetch. Return flat SQL rows; get nested JSON.

Packages

Eleven focused libraries — install only what you need. Same semver on JSR and npm.

Explore the docs

Client shapes the response

JSON or QL queries via headers. The SDK handles encoding — browsers and Node.

One resolver per entity

JoinPlan tells you exactly which fields and joins to fetch. No N+1 resolver maze.

SQL-native

Optional buildSelectSql() for Postgres and SQLite, or ORM adapters for Prisma, Drizzle, and Kysely (v0.6.0).

Your DB connection

MeshQL does not pool connections — pass your Prisma client, pg.Pool, or Drizzle db into the resolver. See the connections guide.

Framework adapters

Express, Fastify, and Hono — plus Deno and Bun guides with the same HTTP contract.

Security plugins

Integrity signing and access control ship as optional @meshql/integrity and @meshql/access plugins.

Works everywhere

Node 22+, Bun, Deno, and modern browsers. JSR for source; npm for compiled ESM.