JSON:API-style
Fields, filters, relations, pagination & sort — one consistent query scheme based on the JSON:API specification.
One query language between client & server. Build JSON:API-style queries on the client, parse them into a typed AST against schema allow-lists on the server — and turn them into SQL or TypeORM queries with composable adapters.
SQL dialect
/users?fields=id,name,age&filter[name]=~to~&filter[age]=%3E%3D21&page[limit]=25&sort=-ageSELECT "id", "name", "age"
FROM "users"
WHERE ("name" ~* $1 and "age" >= $2)
ORDER BY "age" DESC
LIMIT 25 Live — @rapiq/parser-simple, @rapiq/codec-url-simple and @rapiq/sql are running in your browser.
Fields, filters, relations, pagination & sort — one consistent query scheme based on the JSON:API specification.
Input parses into Query nodes that backends consume via the visitor pattern — new targets never touch core.
Declare what clients may request — allowed keys, defaults, mappings. Disallowed input is dropped or throws.
Parse plain objects or an expression language — both dialects produce the exact same Query AST.
Render parameterized SQL for five dialects, or apply a Query straight to a TypeORM SelectQueryBuilder.
Typed key paths via recursive NestedKeys<T> — allow-lists and defaults autocomplete against your records.
rapiq is a family of focused, composable packages. Install only what each side of your application needs — everything meets in the core query AST.
The foundation — query AST, visitor interfaces and the schema system everything else builds on.
Parses plain object/array input — the URL-query-like "simple" dialect.
Parses an expression language into the same Query AST.
URL query-string codec — the transport between client and server.
Dialect-agnostic SQL adapter turning the AST into parameterized fragments.
Applies a parsed Query directly to a TypeORM SelectQueryBuilder.
Build on the client, transport as a query string, parse & validate on the server.
# client side — build & encode queries
npm install @rapiq/core @rapiq/codec-url-simple
# server side — parse, validate & translate
npm install @rapiq/core @rapiq/parser-simple @rapiq/sql@rapiq/typeorm
Apply a parsed Query directly to a SelectQueryBuilder — the adapter walks the AST and mutates the builder, nothing is stringified twice.
import { FiltersVisitor } from '@rapiq/sql';
import { TypeormAdapter } from '@rapiq/typeorm';
const queryBuilder = repository.createQueryBuilder('user');
const adapter = new TypeormAdapter();
adapter.withQuery(queryBuilder);
query.filters.accept(new FiltersVisitor(adapter.filters));
adapter.execute();
const [entities, total] = await queryBuilder.getManyAndCount();