{"id":14970036,"url":"https://github.com/teamstarter/graphql-sequelize-generator","last_synced_at":"2025-08-01T01:08:41.903Z","repository":{"id":33846577,"uuid":"118797791","full_name":"teamstarter/graphql-sequelize-generator","owner":"teamstarter","description":"A Graphql API generator based on Sequelize.","archived":false,"fork":false,"pushed_at":"2025-06-16T09:54:42.000Z","size":1481,"stargazers_count":22,"open_issues_count":13,"forks_count":10,"subscribers_count":17,"default_branch":"develop","last_synced_at":"2025-06-16T10:06:50.163Z","etag":null,"topics":["api","graphql","graphql-api","mutations","resolvers","sequelize"],"latest_commit_sha":null,"homepage":"https://teamstarter.github.io/gsg-documentation/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teamstarter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-24T17:23:55.000Z","updated_at":"2025-03-27T16:37:28.000Z","dependencies_parsed_at":"2024-03-04T17:28:57.125Z","dependency_job_id":"491d1d8e-d835-4cff-a02d-26f24e9a70e3","html_url":"https://github.com/teamstarter/graphql-sequelize-generator","commit_stats":{"total_commits":262,"total_committers":15,"mean_commits":"17.466666666666665","dds":"0.34732824427480913","last_synced_commit":"60fdde369694a01bbc75ce53c84579e28c344adf"},"previous_names":[],"tags_count":75,"template":false,"template_full_name":null,"purl":"pkg:github/teamstarter/graphql-sequelize-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teamstarter%2Fgraphql-sequelize-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teamstarter%2Fgraphql-sequelize-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teamstarter%2Fgraphql-sequelize-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teamstarter%2Fgraphql-sequelize-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teamstarter","download_url":"https://codeload.github.com/teamstarter/graphql-sequelize-generator/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teamstarter%2Fgraphql-sequelize-generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260817155,"owners_count":23067451,"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":["api","graphql","graphql-api","mutations","resolvers","sequelize"],"created_at":"2024-09-24T13:42:55.990Z","updated_at":"2025-06-19T19:37:31.876Z","avatar_url":"https://github.com/teamstarter.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Graphql-Sequelize-Generator\n\nGraphql-Sequelize-Generator (GSG) is a set of tools that will allow you to\neasily generate a GraphQL API from your sequelize models.\n\nIt's a very good fit for POCs and MVPs, while also scaling pretty well thanks to [dataloader-sequelize](https://github.com/mickhansen/dataloader-sequelize).\n\n---\n\n## Documentation\n\nThe complete documentation car be found [here](https://teamstarter.github.io/gsg-documentation/)\n\n## What can I do with GSG?\n\nThe tools provided by this library will allow you to:\n\n- Query any model defined in your app through GraphQL.\n- Auto-generate create/update/delete mutations.\n- Define before/after hooks and all resolvers, including the mutations.\n- Easily create custom mutations.\n- Get an integrated interface to test your GraphQL API.\n- Counts for each model can also be generated.\n- Subscriptions auto-generated for mutations.\n- Add custom fields/resolvers on auto-generated types.\n- Easy integration with [dataloader-sequelize](https://github.com/mickhansen/dataloader-sequelize)\n\n---\n\n## Getting started\n\n---\n\n### Setting up the dependencies and the library\n\nAdd the lib and the peer dependencies of GraphQL-Sequelize-Generator:\n\n```\nyarn add graphql-sequelize-generator graphql sequelize graphql-sequelize @apollo/server dataloader-sequelize graphql-relay ws\n```\n\n⚠️ Caution: GSG requires Node v9.11.2 or greater as it is using async/await.\n\n---\n\n### Initializing the project with Sequelize-CLI and adding data to the database\n\nIf you need to initialize the project, please follow this Sequelize documentation page : [Sequelize-Cli and Migrations](https://sequelize.org/docs/v6/other-topics/migrations/)\n\n---\n\n# Setting up your server\n\nCreate a file where you will set up your server and paste the following code. We used index.js (at the root of our example project):\n\n```javascript\n// index.js\nconst { expressMiddleware } = require('@apollo/server/express4')\nconst express = require('express')\nconst http = require('http')\nconst cors = require('cors')\nconst json = require('body-parser')\nconst { createContext, EXPECTED_OPTIONS_KEY } = require('dataloader-sequelize')\nconst setupServer = require('./schema')\nconst models = require('./models') //Assuming \"models\" is your import of the Sequelize models folder, initialized by Sequelize-Cli\n\nconst createServer = async (options = {}, globalPreCallback = () =\u003e null) =\u003e {\n  const app = express()\n  options = {\n    spdy: { plain: true },\n    ...options,\n  }\n  const httpServer = http.createServer(options, app)\n  const { server } = setupServer(globalPreCallback, httpServer)\n  await server.start()\n  //server.applyMiddleware({ app, path: '/graphql' })\n  app.use(\n    '/graphql',\n    cors(),\n    json(),\n    expressMiddleware(server, {\n      context: async ({ req, connection }) =\u003e {\n        const contextDataloader = createContext(models.sequelize)\n\n        // Connection is provided when a webSocket is connected.\n        if (connection) {\n          // check connection for metadata\n          return {\n            ...connection.context,\n            [EXPECTED_OPTIONS_KEY]: contextDataloader,\n          }\n        }\n      },\n    })\n  )\n\n  await new Promise((resolve) =\u003e {\n    httpServer.listen(process.env.PORT || 8080, () =\u003e {\n      resolve()\n    })\n\n    console.log(\n      `🚀 Server ready at http://localhost:${process.env.PORT || 8080}/graphql`\n    )\n  })\n  return httpServer\n}\n\nconst closeServer = async (server) =\u003e {\n  await Promise.all([new Promise((resolve) =\u003e server.close(() =\u003e resolve()))])\n}\n\ncreateServer()\n```\n\n## Getting started with boilerplates\n\nYou can easily start a project with graphql-sequelize-generator using these boilerplates:\n\n- In JavaScript : [GSG Boilerplate](https://github.com/teamstarter/gsg-boilerplate)\n- In TypeScript : [GSG Typescript Boilerplate](https://github.com/teamstarter/gsg-boilerplate-typescript)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteamstarter%2Fgraphql-sequelize-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteamstarter%2Fgraphql-sequelize-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteamstarter%2Fgraphql-sequelize-generator/lists"}