🧶 a minimal nextjs starter with graphql api routes backed by sequelize
NextJS starter with GraphQL API routes and sequelize to interface with a postgres database. This starter is set up for remote development (i.e. without internet access) -- it uses Apollo's Graphql Playground and a local version of sequelize-cli
.
.env
file based on .env.example
. Optionally update it with different database infoyarn db:seed
yarn
yarn dev
GraphQL playground is available at http://localhost:3000/api/graphql
. The site index displays a list of todo items.
database
config
migrations
models
seeders
graphql
resolvers
schemas
src
pages
api
graphql.js
_app.js
index.js
client
index.js
database
: This folder has been bootstrapped with sequelize-cli
graphql
: Folder for graphql schema and resolverssrc
: Source folder. graphql.js
is the api route. _app.js
imports the Apollo Client from client/index.js
yarn model:generate --name Model --attributes name:string
database/models/model.js
yarn seed:generate --name model-seed
graphql/schema/model.js
. Import and export schema file in graphql/schema/index.js
graphql/resolvers/model.js
. Import and export resolver file in graphql/resolvers/index.js
sequelize-cli
is a dev dependency of this starter, so some of the most frequently used commands have been aliased with yarn.
db:create: create database
db:drop: drop database
db:migrate: run migrations
model:generate: generate a new model. usually used with `--name Name --attributes Attributes`
seed:generate: generate a new seed file. usually used with `--name seed-name`
db:seed: run seed files
db:seed:undo: undo all seed files
db:reseed: drop database, create database, run migrations, seed database
1: I recommend using psql
. Run psql postgres
to spin up a postgres command line. Then run create database ${database_name}
.