https://github.com/bradleyboy/tuql Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} bradleyboy / tuql Public * Notifications * Fork 35 * Star 852 Automatically create a GraphQL server from a SQLite database or a SQL file License MIT license 852 stars 35 forks Star Notifications * Code * Issues 13 * Pull requests 0 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights bradleyboy/tuql This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 2 branches 0 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/b] Use Git or checkout with SVN using the web URL. [gh repo clone bradle] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @bradleyboy bradleyboy Drop Node 8 ... 5e5c09a Jun 6, 2021 Drop Node 8 5e5c09a Git stats * 72 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github/workflows Drop Node 8 June 6, 2021 13:14 .vscode it works November 19, 2017 22:45 src Fix a bug with sqllite default values and inserts (#34) June 6, 2021 13:07 .babelrc it works November 19, 2017 22:45 .editorconfig it works November 19, 2017 22:45 .gitignore ignore demo infile August 25, 2019 13:25 .npmignore ignore demo infile August 25, 2019 13:25 .prettierrc it works November 19, 2017 22:45 LICENSE Create LICENSE November 19, 2017 23:24 Readme.md Update Readme.md June 6, 2021 12:59 package-lock.json 1.7.0 August 25, 2019 13:25 package.json Switching from travis to GH actions September 14, 2019 13:36 View code tuql Installing Using How it works Readme.md tuql build status Coverage Status Pronounced: Too cool tuql is a simple tool that turns a sanely formatted sqlite database into a graphql endpoint. It tries to infer relationships between objects, currently supporting belongsTo, hasMany and belongsToMany. It also forms the basic mutations necessary to create, update, and delete objects, as well as assoicate many-to-many relationships. Installing npm install -g tuql Using tuql --db path/to/database.sqlite You can also optionally set the port and enable graphiql: tuql --db path/to/database.sqlite --port 8888 --graphiql Or, you can use a sql file with statements to build up an in-memory database: tuql --infile path/to/db_dump.sql --graphiql If you'd like to print out the schema itself, use: tuql --db path/to/database.sqlite --schema Or send it to a file: tuql --db path/to/database.sqlite --schema > schema.graphql How it works Imagine your sqlite schema looked something like this: posts users categories category_post id id id category_id user_id username title post_id title body tuql will automatically define models and associations, so that graphql queries like this will work right out of the box: { posts { title body user { username } categories { title } } } tuql works one of two ways. It prefers to map your schema based on the foreign key information in your tables. If foreign keys are not present, tuql assumes the following about your schema in order to map relationships: 1. The primary key column is named id or thing_id or thingId, where thing is the singular form of the table name. Example: For a table named posts, the primary key column should be named id, post_id or postId. 2. Similarly, foreign key columns should be thing_id or thingId, where thing is the singular form of the associated table. 3. For many-to-many associations, the table name should be in the form of foo_bar or bar_foo (ordering is not important). The columns should follow the same pattern as #2 above. About Automatically create a GraphQL server from a SQLite database or a SQL file Topics nodejs graphql schema sqlite sqlite-database sequelize sqlite3 foreign-keys automatic-api Resources Readme License MIT license Stars 852 stars Watchers 22 watching Forks 35 forks Report repository Releases No releases published Packages 0 No packages published Used by 14 * @sredevopsdev * @han0147 * @bojanskr * @daangn * @aphilas * @dotansimha * @zinggrid-demos + 6 Contributors 3 * @bradleyboy bradleyboy Brad Daily * @amilajack amilajack Amila Welihinda * @jondlm jondlm Jon de la Motte Languages * JavaScript 100.0% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.