Log in to GraphQL Editor
Sqlmancer - translate GraphQL queries into SQL statements

Tomek Poniatowicz


Sqlmancer - translate GraphQL queries into SQL statements

Since its open-sourcing, GraphQL keeps on gaining popularity and is becoming used by more & more development teams. Why? What's its secret? It's simple, GraphQL makes describing the complex data dependencies easy and it can be usee with any programming language. The rising popularity created a demand for different tools and libraries facilitating GraphQL implementation & usage across different technologies and vice-versa. Sqlmancer is one of them.

Goals & Features

Sqlmancer is a Node.js library simplifying GraphQL integration with SQL by translating GraphQL queries into SQL statements in a smart way. The flexibility offered by Sqlmancer allows you to create the queries and mutations that suit your schema as well as leaving the decisions to you what types you want to expose in your schema by offering a number of convenient directives. The last but not least, Sqlmancer put annotation over transformation using directives mostly to annotate your schema rather than changing its behavior, aiming to be as aspect-oriented as possible.

Some of the notable features of Sqlmancer:

  • Various dialects supported - you can incorporate Sqlmancer into existing projects regardless of what flavor of SQL you're using as it supports Postgres, MySQL, MariaDB, and SQLite.

  • Advanced sorting & filtering - Add complex sorting and filtering to your data-fetching, including:

    • filtering using logical operators,
    • filtering and sorting by fields
    • filtering by aggregate fields of related models.
  • Performance - Sqlmancer makes the N+1 problem the song of the past by building a single SQL query to fetch all necessary data, regardless of query depth.

  • Custom scalars & Abstract types - Use the scalars that make sense and easily add unions and interfaces into your schema using views or single table inheritance features.

How it works

Sqlmancer generates a type-safe database client basing on your GraphQL schema and metadata provided through a set of schema directives, giving you the ability to query your server for complex data structures with a single SQL query:

Sqlmancer sample resolver

Source: sqlmancer.netlify.app

while keeping your resolver as simple as possible:

Sqlmancer sample query

Source: sqlmancer.netlify.app

Cool, right? If you are interested in for a detailed guide on how to work with the library make sure to visit official Sqlmancer documentation

Still in development

Sqlmancer is still in development. The API is still subject to changes so be aware that there might be some breaking changes coming anytime. As mentioned by the creator feedback and suggestions from the community are more than welcome so if you find a bug, have a feature request, or just want to contribute to this awesome project, feel free to an open issue.

Ready for take-off?

Elevate your work with our editor that combines world-class visual graph, documentation and API console

Get Started with GraphQL Editor