{"id":13394274,"url":"https://github.com/bradleyboy/tuql","last_synced_at":"2025-04-13T02:06:26.550Z","repository":{"id":49359192,"uuid":"111353411","full_name":"bradleyboy/tuql","owner":"bradleyboy","description":"Automatically create a GraphQL server from a SQLite database or a SQL file","archived":false,"fork":false,"pushed_at":"2021-06-06T17:14:12.000Z","size":304,"stargazers_count":1049,"open_issues_count":15,"forks_count":40,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-07-31T17:21:47.061Z","etag":null,"topics":["automatic-api","foreign-keys","graphql","nodejs","schema","sequelize","sqlite","sqlite-database","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bradleyboy.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-20T02:43:15.000Z","updated_at":"2024-07-22T15:25:42.000Z","dependencies_parsed_at":"2022-08-03T00:00:35.637Z","dependency_job_id":null,"html_url":"https://github.com/bradleyboy/tuql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradleyboy%2Ftuql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradleyboy%2Ftuql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradleyboy%2Ftuql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradleyboy%2Ftuql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bradleyboy","download_url":"https://codeload.github.com/bradleyboy/tuql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247117762,"owners_count":20886439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automatic-api","foreign-keys","graphql","nodejs","schema","sequelize","sqlite","sqlite-database","sqlite3"],"created_at":"2024-07-30T17:01:14.554Z","updated_at":"2025-04-04T04:09:06.414Z","avatar_url":"https://github.com/bradleyboy.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Tools","Libraries"],"sub_categories":["Julia Libraries","SQL Libraries","Tools - Miscellaneous","Crystal Libraries"],"readme":"# tuql ![build status](https://github.com/bradleyboy/tuql/actions/workflows/nodejs.yml/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/bradleyboy/tuql/badge.svg?branch=master)](https://coveralls.io/github/bradleyboy/tuql?branch=master)\n\n_Pronounced: Too cool_\n\n**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.\n\n## Installing\n\n`npm install -g tuql`\n\n## Using\n\n`tuql --db path/to/database.sqlite`\n\nYou can also optionally set the port and enable graphiql:\n\n`tuql --db path/to/database.sqlite --port 8888 --graphiql`\n\nOr, you can use a sql file with statements to build up an in-memory database:\n\n`tuql --infile path/to/db_dump.sql --graphiql`\n\nIf you'd like to print out the schema itself, use:\n\n`tuql --db path/to/database.sqlite --schema`\n\nOr send it to a file:\n\n`tuql --db path/to/database.sqlite --schema \u003e schema.graphql`\n\n## How it works\n\nImagine your sqlite schema looked something like this:\n\n| posts | users | categories | category_post |\n| :-: | :-: | :-: | :-: |\n| id      | id | id | category_id |\n| user_id | username | title | post_id |\n| title   | | |\n| body    | | |\n\n**tuql** will automatically define models and associations, so that graphql queries like this will work right out of the box:\n\n```graphql\n{\n  posts {\n    title\n    body\n    user {\n      username\n    }\n    categories {\n      title\n    }\n  }\n}\n```\n\n**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:\n\n1. 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`.\n2. Similarly, foreign key columns should be `thing_id` or `thingId`, where `thing` is the singular form of the associated table.\n3. 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradleyboy%2Ftuql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbradleyboy%2Ftuql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradleyboy%2Ftuql/lists"}