danielrearden / sqlmancer

Conjure SQL from GraphQL queries 🧙🔮✨
https://sqlmancer.netlify.com
MIT License
139 stars 7 forks source link
graphql graphql-js nodejs postgresql sql

Sqlmancer

Conjure SQL from your GraphQL queries 🧙🔮✨

GitHub package.json version GitHub Build Status Coverage Status Language grade: JavaScript Discord

⚠️ This project is currently on hiatus. I am hoping to resume working on Sqlmancer once I have some more free time. Feel free to submit new issues for feature requests or bug reports, although I may not address them immediately.

Sqlmancer is a Node.js library for integrating SQL with GraphQL. It empowers you to effortlessly and efficiently translate GraphQL queries into SQL statements.

How it works

Sqlmancer generates a fluent, type-safe database client from your schema based on metadata you provide through schema directives. With Sqlmancer, your resolver can be as simple as this:

function resolve (root, args, ctx, info) {
  return Film.findMany().resolveInfo(info).execute();
}

while still allowing complex queries like this:

Show query ```graphql query FilmQuery { films( where: { or: [ { budget: { greaterThanOrEqual: 50000000 } }, { language: { name: { in: ["Spanish", "French"] } } }, ] actors: { count: { lessThan: 50 } }, }, orderBy: [{ actors: { avg: { popularity: DESC } } }], limit: 100 ) { id title actors( orderBy: [{ popularity: DESC }], limit: 10 ) { id firstName lastName films( orderBy: [{ films: { min: { budget: ASC } } }] limit: 5 ) { id title } } } } ```

Features

Design goals

See the official documentation for API reference, guides and more.

Community

If you found a bug, have a feature request or want to contribute to the project, please open an issue. If you need help or have a question, you can ask on Stack Overflow or come chat with us on Discord!

Contributors

Thanks goes to these wonderful people (emoji key):


Daniel Rearden

💻 📖 🤔

Pavel Ravits

📖

Tadej Stanic

🐛

Tristan Siegel

💻

This project follows the all-contributors specification. Contributions of any kind welcome!