Hyperwindmill/morphql: Transform data with queries


MorphQL

Transform Data with Declarative Queries

A high-performance engine that compiles transformation queries into optimized JavaScript functions.

Isomorphic · Type-Safe · Fast

The Problem
The Solution
Quick Start
DOCUMENTATION


“I was tired of rewriting one-off data consumers for every integration.”

In modern software development, data transformation is everywhere. Whether you’re shaping API responses, processing ETL pipelines, or integrating third-party services, you inevitably face:

  • Complex mapping logic scattered across your codebase.
  • Performance bottlenecks when processing large datasets.
  • Format juggling between JSON, XML, and native Objects.
  • Inconsistent transformations across different microservices.
  • Debugging nightmares with deeply nested, imperative mapping code.

And if you rely on AI or LLMs to generate transformations, the problems multiply: verbose JavaScript consumes tokens, and imperative loops create countless “valid but wrong” states for models to hallucinate.


MorphQL (Morph Query Language) flips the script. Instead of writing how to transform data, you declare what you want.

from json to json
transform
  set fullName = firstName + " " + lastName
  set isAdult = age >= 18

This declarative query is then compiled into a specialized JavaScript function that runs at native speed. Compile once, execute millions of times.

Feature Benefit
Declarative DSL Write what you want, not how to loop and assign. Queries are self-documenting.
Native Performance Queries compile to optimized JavaScript. No runtime interpretation overhead.
Format Agnostic Built-in format conversion (JSON ↔ XML ↔ Object) in a single query.
Centralized Logic Keep transformation logic separate and portable.
Inspectable Code The generated code is readable JavaScript—debug it if needed.
LLM Efficient Constrained DSL reduces token cost and hallucinations compared to generating imperative JS.

To set the right expectations:

  • Not an iPaaS — MorphQL doesn’t manage connectors, orchestration, or SaaS integrations. It’s a transformation engine, not a platform.
  • Not low-code — There’s no drag-and-drop UI. You write queries in a DSL designed for developers.
  • Not for business users — This is a tool for engineers who need precise control over data shaping.

If you’re looking for a point-and-click integration builder, this isn’t it. If you need a fast, embeddable transformation engine you can control—keep reading.


npm install @morphql/core
import { compile, morphQL } from "@morphql/core";

// Define your transformation
const query = morphQL`
  from object to json
  transform
    set greeting = "Hello, " + name + "!"
    set isAdult = age >= 18
`;

// Compile once
const engine = await compile(query);

// Execute many times
const result = engine({ name: "Alice", age: 25 });
// → '{"greeting":"Hello, Alice!","isAdult":true}'

💡 Tip: Use the morphQL tagged template for syntax highlighting in VSCode and JetBrains IDEs.


MorphQL is available in multiple forms to fit your workflow:

Package Description Use Case
@morphql/core Core transformation engine Embed in Node.js or browser apps. Compile once, execute fast.
@morphql/cli Command-line interface Scripting, batch processing, piping with Unix tools.
@morphql/server REST API server with Redis caching Production microservices with Staged Queries for pre-defined endpoints.
@morphql/playground Interactive web editor Experiment with queries in the browser with live feedback.

💬 “So with the server package and a custom adapter, I could create APIs on my data directly?”

Yes, you could. Define a transformation, point it at your data source, and you have a live API endpoint—no boilerplate, no middleware sprawl.


🔄 API Response Shaping

Transform backend responses into frontend-friendly formats without cluttering your application code.

Compile transformations once and process millions of records at native JavaScript speed.

Convert between JSON, XML, and Objects with zero boilerplate—just declare source and target.

🧩 Nested Data Processing

Handle complex structures with subqueries that can even parse embedded formats (e.g., XML inside a JSON field).


👉 Full Documentation — Language reference, architecture guides, and advanced patterns.


Planned / Missing Features

MorphQL is actively evolving, I have lots of ideas, but I’d be also interested in your feedback on real-world integration scenarios and problems you are trying to solve.

Feel free to open an issue or join the discussion section on GitHub (https://github.com/Hyperwindmill/morphql/discussions)


MIT © 2026



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *