https://github.com/joist-orm/joist-graphql-sample
joist sample with graphql scaffolding
https://github.com/joist-orm/joist-graphql-sample
Last synced: 1 day ago
JSON representation
joist sample with graphql scaffolding
- Host: GitHub
- URL: https://github.com/joist-orm/joist-graphql-sample
- Owner: joist-orm
- Created: 2023-03-28T00:33:29.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2026-05-20T22:11:35.000Z (about 1 month ago)
- Last Synced: 2026-06-16T08:33:23.928Z (6 days ago)
- Language: TypeScript
- Size: 2.99 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
# Joist Sample App
This is a bare minimum sample app using Joist as an ORM.
There are two domain objects, `Author` and `Book`, and a single test, `Author.test.ts`.
There are no examples of business logic or Joist's various features; for those see the docs.
## Setup
- `yarn i`
- `docker-compose up -d db`
- `yarn pg-migrate`
- `yarn joist-codegen` (if you've made migration/schema changes)
- `yarn test`
## Example Workflow
A typical workflow for adding a new entity looks like:
- Run `npm run pg-new-migration "add book review"`
- Edit the `migrations/...add-book-review.ts` file and add
```typescript
createEntityTable(pgm, "book_reviews", {
book_id: foreignKey("books"),
rating: { type: "integer", notNull: true },
});
```
- Run `yarn pg-migrate`
- If you change your migration, and want to re-apply it from scratch, run `docker-compose exec db ./reset.sh`
- Run `yarn joist-codegen`
- Copy/paste the `Author.test.ts` and write a test for `Publisher`
## Steps Taken to Setup This Repo
TODO: Automate this with more, probably with mrm.
- Install basic prettier/TypeScript/jest.
```shell
npm install -g mrm
npm install -g \
@homebound/mrm-tasks-prettier \
@homebound/mrm-tasks-gitignore \
@homebound/mrm-tasks-typescript
mrm @homebound/mrm-tasks-prettier \
@homebound/mrm-tasks-gitignore \
@homebound/mrm-tasks-typescript
```
- Copy/paste `migrations/...author.ts`
- Add `joist-orm`, `joist-migration-utils`, `joist-codegen` to `package.json`
- Copy/paste `.env`, changed port
- Add `tsx`, `env-cmd` to `package.json`
- Should come from `mrm`?
- Add `pg-migrate` script, run it
- Add `joist-codegen` script, run it
- Add `Author.test.ts`
- Add `dotenv` to `package.json`
- Add `pg-new-migration` to `package.json`
- Add `.gitattributes` to suppress diffs on generated files