Making GraphQL Magic with Sqlmancer 🧙🔮✨

Daniel Rearden

Backend Engineer
GraphQL
MySQL
Node.js
PostgreSQL
TypeScript

Today I'm excited to announce the beta release of Sqlmancer! Sqlmancer is a Node.js library that empowers you to effortlessly and efficiently translate GraphQL queries into SQL statements. This article will walk through setting up a project with Sqlmancer and showcase a few of its many features:

  • Multiple dialect support. Sqlmancer supports Postgres, MySQL, MariaDB and SQLite, enabling you to incorporate it into existing projects regardless of what flavor of SQL you're using.
  • Performance. Avoid the N+1 problem by building a single SQL query to fetch all necessary data, regardless of query depth.
  • Robust filtering and sorting. Add complex filtering and sorting to your queries, including filtering using logical operators and filtering and sorting by fields and aggregate fields of related models.
  • Arbitrarily deep nesting. Define one-to-one, one-to-many and many-to-many relationships between models. Related models can be filtered, sorted and paginated just like root-level fields.
  • Mutations made easy. Create, update and delete records, with or without transactions, using a simple, fluent API.
  • Views and CTEs. Take advantage of existing views in your database or create inline ones using common table expressions.
  • Custom scalars. Use the scalars that make sense for your schema.
  • Abstract types. Utilize unions and interfaces in your schema using views or single table inheritance.

Continue reading on DEV



Partner With Daniel
View Services

More Projects by Daniel