{"id":18895876,"url":"https://github.com/echobind/sequelize-graphql-next-template","last_synced_at":"2026-02-28T01:30:18.729Z","repository":{"id":98472231,"uuid":"397718695","full_name":"echobind/sequelize-graphql-next-template","owner":"echobind","description":null,"archived":false,"fork":false,"pushed_at":"2021-08-18T23:58:43.000Z","size":73,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-16T12:13:56.192Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/echobind.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2021-08-18T19:49:24.000Z","updated_at":"2021-08-19T00:09:40.000Z","dependencies_parsed_at":"2023-06-01T21:45:30.025Z","dependency_job_id":null,"html_url":"https://github.com/echobind/sequelize-graphql-next-template","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/echobind%2Fsequelize-graphql-next-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echobind%2Fsequelize-graphql-next-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echobind%2Fsequelize-graphql-next-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echobind%2Fsequelize-graphql-next-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/echobind","download_url":"https://codeload.github.com/echobind/sequelize-graphql-next-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239870516,"owners_count":19710736,"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":[],"created_at":"2024-11-08T08:30:57.597Z","updated_at":"2026-02-28T01:30:18.678Z","avatar_url":"https://github.com/echobind.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## What is this?\n- you want to quickly spin up a new nextjs app that has an api layer with graphql, sequelize, and mssql\n\n## How do I use this\n- clone this repo\n- you'll need node@16.x.x installed\n- from the parent directory, run `bash sequelize-graphql-next-template/main.sh`\n\n## What main.sh does\n- create a new app with nextjs\n\t- `npx create-next-app [app name]`\n- set up env variables\n\t- copy the .env.template from this repo into your nextjs app\n\t- `cp .env.template ../[app name]/.env`\n\t- provide the values to those env variables, you'll find them from your mssql database\n\t- you'll also want to copy that .env.template into another .env.template file in your new app so that other contributors will know what they need to set up\n\t- git ignore the .env file\n- install the dependencies that are in this package.json\n- set up sequelize:\n\t- `cp db.config.js ../[your app]`\n\t- `cp .sequelizeerc ../[your app]`\n\t- `npx sequelize init`\n\t- `cp ./db/config/config.js ../[your app]/db/config/config.js`\n\t\t- you'll probably want to modify this file for your other environments when you start deploying\n\t- `cp ./db/models/index.js ../[your app]/db/models/index.js\n- set up graphql\n\t- `cp ./graphql -R ../[your app]/graphql`\n\t- `cp ./pages/api/graphql.js ../[your app]/pages/api`\n\t- `cp ./pages/api/rest.js ../[your app]/pages/api`\n\t- `cp ./pages/_app.js ../[your app]/pages/_app.js`\n- run the app and check the state of things\n\t- `npm run dev`,\n\t\t- open browser to localhost:3000, you should see the nextjs sample page\n\t\t- navigate to `/api/rest`, you should see some dummy json content\n\t\t- navigate to `/api/graphql`, you should see the apollographql studio with a dummy query and dummy mutation\n\n## Building your app, api driven first\n- generate a model with sequelize\n\t- example: `npx sequelize model:create --name User --attributes firstName:stringlastName:string,email:string`\n\t\t- name field is the name of the table\n\t\t- attributes isn't required, but you can specify the columns and their types\n\t\t- after you've generated you're table, make any changes in the `db/models/[tablename].js`, explore [ways](https://sequelize.org/v5/manual/models-definition.html) to modify the table's columns\n\t- add associations\n\t- the cli script that created the model also created a migration that adds the table to the database\n\t- this creates a file with a time stamp and the name of the migration in the db/migrations directory\n\t- `npx sequelize db:migrate`\n- generate a seed for your model\n\t- `npx sequelize seed:generate --name users`\n\t- find the seed file and fill it out with some data\n\t- `npx sequelize db:seed:all`\n\t- modify /api/test.js so that it calls `db.user.findAll()` and returns the results to the page and check `/api/rest`, and you should see your seed data\n- graphql\n\t- first define your User type in graphql/schema/index.js and add it to the Query type\n\t- then define your mutations\n\t\t- create a file that matches the name of your model in graphql/resolvers, in our case, it would be user.js. You should export an object that has a queries field and a mutations field. Each of those two fields should contain an object with a set of async functions that invoke methods from sequelize. Remember the graphql resolver [arguments](https://www.apollographql.com/docs/apollo-server/data/resolvers/#resolver-arguments), you can access the sequelize methods from context[model name], and your model names will match the filel name in db/models/*.js\n\t\t- now in /graphql/resolvers/index.js, import your resolvers, and spread each set of resolver functions into their approapriate slot\n\t\t- last, be sure to add the mutations and queryies to graphql/schema/index.js\n\t\t- now check localhost:3000/api/graphql and you should be able to run your queries and mutations\n- from there, you can start creating your views with react\n- to use your graphql endpoint, take a look at [@apollo/client](https://www.apollographql.com/docs/react/)\n\n## additional links\n- [sequelize-cli](https://github.com/sequelize/cli)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fechobind%2Fsequelize-graphql-next-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fechobind%2Fsequelize-graphql-next-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fechobind%2Fsequelize-graphql-next-template/lists"}