create-joist-app 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/build/create-app.test.js +3 -3
  2. package/build/create-app.test.js.map +1 -1
  3. package/build/create-db-dockerfile.js +4 -4
  4. package/package.json +2 -2
  5. package/templates/basic/README.md +0 -70
  6. package/templates/basic/gitignore +0 -28
  7. package/templates/basic/jest.config.js +0 -14
  8. package/templates/basic/joist-config.json +0 -7
  9. package/templates/basic/migrations/1580658856631_initial.ts +0 -22
  10. package/templates/basic/package.json +0 -28
  11. package/templates/basic/src/context.ts +0 -14
  12. package/templates/basic/src/entities/Author.test.ts +0 -17
  13. package/templates/basic/src/entities/Author.ts +0 -7
  14. package/templates/basic/src/entities/Book.ts +0 -3
  15. package/templates/basic/src/entities/entities.ts +0 -14
  16. package/templates/basic/src/entities/factories/index.ts +0 -2
  17. package/templates/basic/src/entities/factories/newAuthor.ts +0 -6
  18. package/templates/basic/src/entities/factories/newBook.ts +0 -6
  19. package/templates/basic/src/entities/index.ts +0 -3
  20. package/templates/basic/src/setupTestEnv.ts +0 -5
  21. package/templates/basic/src/setupTests.ts +0 -29
  22. package/templates/basic/tsconfig.json +0 -23
  23. package/templates/graphql/README.md +0 -84
  24. package/templates/graphql/codegen.yml +0 -11
  25. package/templates/graphql/gitignore +0 -28
  26. package/templates/graphql/graphql-codegen-joist.js +0 -5
  27. package/templates/graphql/graphql-codegen.js +0 -26
  28. package/templates/graphql/jest.config.js +0 -14
  29. package/templates/graphql/joist-config.json +0 -8
  30. package/templates/graphql/migrations/1580658856631_initial.ts +0 -38
  31. package/templates/graphql/package.json +0 -41
  32. package/templates/graphql/schema/.history.json +0 -9
  33. package/templates/graphql/schema/author.graphql +0 -20
  34. package/templates/graphql/schema/book.graphql +0 -19
  35. package/templates/graphql/schema/enums.graphql +0 -0
  36. package/templates/graphql/schema/root.graphql +0 -0
  37. package/templates/graphql/src/.history.json +0 -12
  38. package/templates/graphql/src/context.ts +0 -14
  39. package/templates/graphql/src/entities/Author.test.ts +0 -36
  40. package/templates/graphql/src/entities/Author.ts +0 -7
  41. package/templates/graphql/src/entities/Book.ts +0 -3
  42. package/templates/graphql/src/entities/entities.ts +0 -14
  43. package/templates/graphql/src/entities/factories/index.ts +0 -2
  44. package/templates/graphql/src/entities/factories/newAuthor.ts +0 -6
  45. package/templates/graphql/src/entities/factories/newBook.ts +0 -6
  46. package/templates/graphql/src/entities/index.ts +0 -3
  47. package/templates/graphql/src/jest.d.ts +0 -9
  48. package/templates/graphql/src/resolvers/author/authorResolvers.test.ts +0 -17
  49. package/templates/graphql/src/resolvers/author/authorResolvers.ts +0 -5
  50. package/templates/graphql/src/resolvers/author/saveAuthorMutation.test.ts +0 -13
  51. package/templates/graphql/src/resolvers/author/saveAuthorMutation.ts +0 -9
  52. package/templates/graphql/src/resolvers/book/bookResolvers.test.ts +0 -17
  53. package/templates/graphql/src/resolvers/book/bookResolvers.ts +0 -5
  54. package/templates/graphql/src/resolvers/book/saveBookMutation.test.ts +0 -16
  55. package/templates/graphql/src/resolvers/book/saveBookMutation.ts +0 -9
  56. package/templates/graphql/src/resolvers/enumResolvers.ts +0 -5
  57. package/templates/graphql/src/resolvers/index.ts +0 -15
  58. package/templates/graphql/src/resolvers/mutations/index.ts +0 -7
  59. package/templates/graphql/src/resolvers/objects/index.ts +0 -6
  60. package/templates/graphql/src/resolvers/testUtils.ts +0 -10
  61. package/templates/graphql/src/resolvers/utils.ts +0 -1
  62. package/templates/graphql/src/server.ts +0 -37
  63. package/templates/graphql/src/setupIt.ts +0 -17
  64. package/templates/graphql/src/setupTestEnv.ts +0 -5
  65. package/templates/graphql/src/setupTests.ts +0 -37
  66. package/templates/graphql/tsconfig.json +0 -23
@@ -124,11 +124,11 @@ describe("createApp", () => {
124
124
  expect(fs_1.default.existsSync(path_1.default.join(projectPath, "joist-config.json"))).toBe(true);
125
125
  // Check GraphQL-specific files
126
126
  expect(fs_1.default.existsSync(path_1.default.join(projectPath, "codegen.yml"))).toBe(true);
127
- expect(fs_1.default.existsSync(path_1.default.join(projectPath, "src/schema.graphql"))).toBe(true);
127
+ expect(fs_1.default.existsSync(path_1.default.join(projectPath, "schema/root.graphql"))).toBe(true);
128
128
  expect(fs_1.default.existsSync(path_1.default.join(projectPath, "src/server.ts"))).toBe(true);
129
129
  expect(fs_1.default.existsSync(path_1.default.join(projectPath, "src/resolvers/index.ts"))).toBe(true);
130
- expect(fs_1.default.existsSync(path_1.default.join(projectPath, "src/resolvers/authorResolvers.ts"))).toBe(true);
131
- expect(fs_1.default.existsSync(path_1.default.join(projectPath, "src/resolvers/bookResolvers.ts"))).toBe(true);
130
+ expect(fs_1.default.existsSync(path_1.default.join(projectPath, "src/resolvers/author/authorResolvers.ts"))).toBe(true);
131
+ expect(fs_1.default.existsSync(path_1.default.join(projectPath, "src/resolvers/book/bookResolvers.ts"))).toBe(true);
132
132
  });
133
133
  it("includes graphql codegen plugin in joist-config", async () => {
134
134
  const projectPath = path_1.default.join(tempDir, "graphql-project");
@@ -1 +1 @@
1
- {"version":3,"file":"create-app.test.js","sourceRoot":"","sources":["../src/create-app.test.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,6CAAyC;AAEzC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,OAAe,CAAC;IAEpB,UAAU,CAAC,GAAG,EAAE;QACd,OAAO,GAAG,YAAE,CAAC,WAAW,CAAC,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,wBAAwB,CAAC,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,YAAE,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,QAA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C,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;YAC7F,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;YAC7D,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -7,10 +7,10 @@ exports.createDbDockerfile = createDbDockerfile;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  function createDbDockerfile(projectPath) {
10
- const dbDockerfile = `FROM postgres:16
10
+ const dbDockerfile = `FROM postgres:18
11
11
 
12
12
  # Script to reset the database
13
- COPY <<EOF /docker-entrypoint-initdb.d/reset.sh
13
+ COPY <<'EOF' /docker-entrypoint-initdb.d/reset.sh
14
14
  #!/bin/bash
15
15
  set -e
16
16
  psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname postgres <<-EOSQL
@@ -21,7 +21,7 @@ EOF
21
21
  RUN chmod +x /docker-entrypoint-initdb.d/reset.sh
22
22
 
23
23
  # Copy reset script to accessible location
24
- COPY <<EOF /reset.sh
24
+ COPY <<'EOF' /reset.sh
25
25
  #!/bin/bash
26
26
  set -e
27
27
  psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname postgres <<-EOSQL
@@ -32,7 +32,7 @@ EOF
32
32
  RUN chmod +x /reset.sh
33
33
 
34
34
  # Console script for easy database access
35
- COPY <<EOF /console.sh
35
+ COPY <<'EOF' /console.sh
36
36
  #!/bin/bash
37
37
  psql -U "$POSTGRES_USER" -d "$POSTGRES_DB"
38
38
  EOF
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-joist-app",
3
- "version": "0.0.1",
3
+ "version": "1.0.0",
4
4
  "description": "Create a new Joist ORM project with a single command",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -52,4 +52,4 @@
52
52
  "engines": {
53
53
  "node": ">=18.0.0"
54
54
  }
55
- }
55
+ }
@@ -1,70 +0,0 @@
1
- # {{PROJECT_NAME}}
2
-
3
- A [Joist ORM](https://joist-orm.io/) project.
4
-
5
- ## Getting Started
6
-
7
- ### Prerequisites
8
-
9
- - Node.js 18+
10
- - Docker (for PostgreSQL)
11
-
12
- ### Setup
13
-
14
- 1. Start the database and run initial setup:
15
-
16
- ```bash
17
- yarn db
18
- ```
19
-
20
- This command will:
21
- - Start a PostgreSQL container
22
- - Run database migrations
23
- - Generate Joist entity code
24
-
25
- ### Development
26
-
27
- #### Running Tests
28
-
29
- ```bash
30
- yarn test
31
- ```
32
-
33
- #### Creating a New Migration
34
-
35
- ```bash
36
- yarn migrate:new my-migration-name
37
- ```
38
-
39
- Then edit the generated file in `migrations/` and run:
40
-
41
- ```bash
42
- yarn migrate
43
- yarn codegen
44
- ```
45
-
46
- #### Resetting the Database
47
-
48
- ```bash
49
- yarn redb
50
- ```
51
-
52
- ### Project Structure
53
-
54
- ```
55
- ├── migrations/ # Database migrations
56
- ├── src/
57
- │ ├── entities/ # Joist entities
58
- │ │ ├── codegen/ # Generated code (do not edit)
59
- │ │ └── factories/ # Test factories
60
- │ ├── context.ts # Request context
61
- │ ├── setupTestEnv.ts # Global test setup
62
- │ └── setupTests.ts # Per-suite test setup
63
- ├── docker-compose.yml # PostgreSQL service
64
- └── joist-config.json # Joist configuration
65
- ```
66
-
67
- ## Learn More
68
-
69
- - [Joist Documentation](https://joist-orm.io/)
70
- - [GitHub Repository](https://github.com/joist-orm/joist-orm)
@@ -1,28 +0,0 @@
1
- # Dependencies
2
- node_modules/
3
-
4
- # Build output
5
- build/
6
- dist/
7
-
8
- # IDE
9
- .idea/
10
- .vscode/
11
- *.swp
12
- *.swo
13
-
14
- # OS
15
- .DS_Store
16
- Thumbs.db
17
-
18
- # Test output
19
- coverage/
20
-
21
- # Logs
22
- *.log
23
- npm-debug.log*
24
- yarn-debug.log*
25
- yarn-error.log*
26
-
27
- # TypeScript
28
- *.tsbuildinfo
@@ -1,14 +0,0 @@
1
- /** @type {import('jest').Config} */
2
- module.exports = {
3
- transform: {
4
- "^.+\\.tsx?$": "@swc/jest",
5
- },
6
- moduleNameMapper: {
7
- "^src/(.*)$": "<rootDir>/src/$1",
8
- },
9
- testMatch: ["<rootDir>/src/**/*.test.{ts,tsx}"],
10
- testEnvironment: "node",
11
- globalSetup: "./src/setupTestEnv.ts",
12
- setupFilesAfterEnv: ["./src/setupTests.ts"],
13
- maxWorkers: 1,
14
- };
@@ -1,7 +0,0 @@
1
- {
2
- "contextType": "Context@src/context",
3
- "entities": { "Author": { "tag": "a" }, "Book": { "tag": "b" } },
4
- "entitiesDirectory": "./src/entities",
5
- "idType": "tagged-string",
6
- "version": "0.0.0"
7
- }
@@ -1,22 +0,0 @@
1
- import {
2
- createCreatedAtFunction,
3
- createEntityTable,
4
- createUpdatedAtFunction,
5
- foreignKey,
6
- } from "joist-migration-utils";
7
- import { MigrationBuilder } from "node-pg-migrate";
8
-
9
- export function up(b: MigrationBuilder): void {
10
- createUpdatedAtFunction(b);
11
- createCreatedAtFunction(b);
12
-
13
- createEntityTable(b, "authors", {
14
- first_name: { type: "varchar(255)", notNull: true },
15
- last_name: { type: "varchar(255)", notNull: false },
16
- });
17
-
18
- createEntityTable(b, "books", {
19
- title: { type: "varchar(255)", notNull: true },
20
- author_id: foreignKey("authors", { notNull: true }),
21
- });
22
- }
@@ -1,28 +0,0 @@
1
- {
2
- "name": "basic-template",
3
- "version": "0.1.0",
4
- "private": true,
5
- "scripts": {
6
- "build": "tsc",
7
- "test": "env-cmd jest --runInBand",
8
- "codegen": "env-cmd yarn joist-codegen",
9
- "format": "prettier --write \"src/**/*.{ts,tsx}\""
10
- },
11
- "dependencies": {
12
- "@types/pg": "^8.18.0",
13
- "joist-orm": "2.0.3-next.36",
14
- "pg": "^8.16.3"
15
- },
16
- "devDependencies": {
17
- "@swc/core": "^1.13.0",
18
- "@swc/jest": "^0.2.39",
19
- "@types/jest": "^30.0.0",
20
- "@types/node": "^24.0.0",
21
- "env-cmd": "^11.0.0",
22
- "jest": "^30.0.0",
23
- "node-pg-migrate": "^8.0.4",
24
- "prettier": "^3.6.0",
25
- "tsx": "^4.20.0",
26
- "typescript": "^5.9.0"
27
- }
28
- }
@@ -1,14 +0,0 @@
1
- import { EntityManager, newPgConnectionConfig } from "joist-orm";
2
- import { PostgresDriver } from "joist-orm/pg";
3
- import { Pool } from "pg";
4
-
5
- export interface Context {
6
- pool: Pool;
7
- em: EntityManager;
8
- }
9
-
10
- export function newContext(): Context {
11
- const pool = new Pool(newPgConnectionConfig());
12
- const em = new EntityManager({}, new PostgresDriver(pool));
13
- return { em, pool };
14
- }
@@ -1,17 +0,0 @@
1
- import { newEm } from "../setupTests";
2
- import { newAuthor, newBook } from "./factories";
3
-
4
- describe("Author", () => {
5
- it("can create an author", async () => {
6
- const em = newEm();
7
- newAuthor(em, { firstName: "John", lastName: "Doe" });
8
- await em.flush();
9
- });
10
-
11
- it("can have books", async () => {
12
- const em = newEm();
13
- const author = newAuthor(em, { firstName: "Test", lastName: "Author" });
14
- newBook(em, { title: "Test Book", author });
15
- await em.flush();
16
- });
17
- });
@@ -1,7 +0,0 @@
1
- import { AuthorCodegen } from "./codegen/AuthorCodegen";
2
-
3
- export class Author extends AuthorCodegen {
4
- get fullName(): string {
5
- return `${this.firstName} ${this.lastName}`;
6
- }
7
- }
@@ -1,3 +0,0 @@
1
- import { BookCodegen } from "./codegen/BookCodegen";
2
-
3
- export class Book extends BookCodegen {}
@@ -1,14 +0,0 @@
1
- // organize-imports-ignore
2
-
3
- // This file drives our import order to avoid undefined errors
4
- // when the subclasses extend the base classes, see:
5
- // https://medium.com/visual-development/how-to-fix-nasty-circular-dependency-issues-once-and-for-all-in-javascript-typescript-a04c987cf0de
6
-
7
- export * from "./codegen/AuthorCodegen";
8
- export * from "./codegen/BookCodegen";
9
- export * from "./Author";
10
- export * from "./Book";
11
-
12
- export * from "./factories/newAuthor";
13
- export * from "./factories/newBook";
14
- export * from "./codegen/metadata";
@@ -1,2 +0,0 @@
1
- export * from "./newAuthor";
2
- export * from "./newBook";
@@ -1,6 +0,0 @@
1
- import { EntityManager, FactoryOpts, newTestInstance } from "joist-orm";
2
- import { Author } from "../entities";
3
-
4
- export function newAuthor(em: EntityManager, opts?: FactoryOpts<Author>): Author {
5
- return newTestInstance(em, Author, opts);
6
- }
@@ -1,6 +0,0 @@
1
- import { EntityManager, FactoryOpts, newTestInstance } from "joist-orm";
2
- import { Book } from "../entities";
3
-
4
- export function newBook(em: EntityManager, opts?: FactoryOpts<Book>): Book {
5
- return newTestInstance(em, Book, opts);
6
- }
@@ -1,3 +0,0 @@
1
- export * from "./entities";
2
- export * from "./Author";
3
- export * from "./Book";
@@ -1,5 +0,0 @@
1
- import { GetEnvVars } from "env-cmd";
2
-
3
- export default async function globalSetup() {
4
- Object.entries(await GetEnvVars()).forEach(([key, value]) => (process.env[key] = value));
5
- }
@@ -1,29 +0,0 @@
1
- import expect from "expect";
2
- import { newPgConnectionConfig } from "joist-orm";
3
- import { PostgresDriver } from "joist-orm/pg";
4
- import { toMatchEntity } from "joist-orm/tests";
5
- import pg from "pg";
6
- import { Context } from "./context";
7
- import { EntityManager } from "./entities";
8
-
9
- expect.extend({ toMatchEntity });
10
-
11
- let pool: pg.Pool;
12
-
13
- beforeAll(async () => {
14
- pool = new pg.Pool(newPgConnectionConfig());
15
- });
16
-
17
- beforeEach(async () => {
18
- await pool.query("select flush_database()");
19
- });
20
-
21
- afterAll(async () => {
22
- await pool.end();
23
- });
24
-
25
- export function newEm(): EntityManager {
26
- const driver = new PostgresDriver(pool);
27
- const ctx = { pool, em: null as any } satisfies Context;
28
- return new EntityManager(ctx, driver);
29
- }
@@ -1,23 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "nodenext",
5
- "lib": ["ES2022"],
6
- "moduleResolution": "nodenext",
7
- "esModuleInterop": true,
8
- "strict": true,
9
- "skipLibCheck": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "declaration": true,
12
- "declarationMap": true,
13
- "sourceMap": true,
14
- "outDir": "./build",
15
- "rootDir": "./src",
16
- "baseUrl": "./src",
17
- "paths": {
18
- "src/*": ["./*"]
19
- }
20
- },
21
- "include": ["src"],
22
- "exclude": ["node_modules", "build"]
23
- }
@@ -1,84 +0,0 @@
1
- # {{PROJECT_NAME}}
2
-
3
- A [Joist ORM](https://joist-orm.io/) project with GraphQL.
4
-
5
- ## Getting Started
6
-
7
- ### Prerequisites
8
-
9
- - Node.js 18+
10
- - Docker (for PostgreSQL)
11
-
12
- ### Setup
13
-
14
- 1. Start the database and run initial setup:
15
-
16
- ```bash
17
- yarn db
18
- ```
19
-
20
- This command will:
21
- - Start a PostgreSQL container
22
- - Run database migrations
23
- - Generate Joist entity code and GraphQL types
24
-
25
- ### Development
26
-
27
- #### Starting the Server
28
-
29
- ```bash
30
- yarn dev
31
- ```
32
-
33
- The GraphQL server will start at http://localhost:4000
34
-
35
- #### Running Tests
36
-
37
- ```bash
38
- yarn test
39
- ```
40
-
41
- #### Creating a New Migration
42
-
43
- ```bash
44
- yarn migrate:new my-migration-name
45
- ```
46
-
47
- Then edit the generated file in `migrations/` and run:
48
-
49
- ```bash
50
- yarn migrate
51
- yarn codegen
52
- ```
53
-
54
- #### Resetting the Database
55
-
56
- ```bash
57
- yarn redb
58
- ```
59
-
60
- ### Project Structure
61
-
62
- ```
63
- ├── migrations/ # Database migrations
64
- ├── src/
65
- │ ├── entities/ # Joist entities
66
- │ │ ├── codegen/ # Generated entity code (do not edit)
67
- │ │ └── factories/ # Test factories
68
- │ ├── resolvers/ # GraphQL resolvers
69
- │ ├── generated/ # Generated GraphQL types (do not edit)
70
- │ ├── context.ts # Request context
71
- │ ├── schema.graphql # GraphQL schema
72
- │ ├── server.ts # Apollo Server setup
73
- │ ├── setupTestEnv.ts # Global test setup
74
- │ └── setupTests.ts # Per-suite test setup
75
- ├── docker-compose.yml # PostgreSQL service
76
- ├── joist-config.json # Joist configuration
77
- └── codegen.yml # GraphQL codegen configuration
78
- ```
79
-
80
- ## Learn More
81
-
82
- - [Joist Documentation](https://joist-orm.io/)
83
- - [Apollo Server](https://www.apollographql.com/docs/apollo-server/)
84
- - [GitHub Repository](https://github.com/joist-orm/joist-orm)
@@ -1,11 +0,0 @@
1
- schema: "./src/**/*.graphql"
2
- generates:
3
- ./src/generated/graphql-types.ts:
4
- plugins:
5
- - typescript
6
- - typescript-resolvers
7
- config:
8
- contextType: "../context#Context"
9
- mappers:
10
- Author: ../entities#Author
11
- Book: ../entities#Book
@@ -1,28 +0,0 @@
1
- # Dependencies
2
- node_modules/
3
-
4
- # Build output
5
- build/
6
- dist/
7
-
8
- # IDE
9
- .idea/
10
- .vscode/
11
- *.swp
12
- *.swo
13
-
14
- # OS
15
- .DS_Store
16
- Thumbs.db
17
-
18
- # Test output
19
- coverage/
20
-
21
- # Logs
22
- *.log
23
- npm-debug.log*
24
- yarn-debug.log*
25
- yarn-error.log*
26
-
27
- # TypeScript
28
- *.tsbuildinfo
@@ -1,5 +0,0 @@
1
- const mappers = { Author: "src/entities#Author", Book: "src/entities#Book" };
2
-
3
- const enumValues = {};
4
-
5
- module.exports = { mappers, enumValues };
@@ -1,26 +0,0 @@
1
- const { mappers, enumValues } = require("./graphql-codegen-joist");
2
-
3
- module.exports = {
4
- overwrite: true,
5
- schema: "./schema/**/*.graphql",
6
- documents: null,
7
- generates: {
8
- "src/generated/graphql-types.ts": {
9
- config: {
10
- contextType: "src/context#Context",
11
- noSchemaStitching: true,
12
- avoidOptionals: true,
13
- scaffolding: {
14
- ignoreObjectsPattern: "Detail$",
15
- },
16
- mappers,
17
- enumValues,
18
- },
19
- plugins: [
20
- "@homebound/graphql-typescript-simple-resolvers",
21
- "@homebound/graphql-typescript-resolver-scaffolding",
22
- "@homebound/graphql-typescript-possible-types",
23
- ],
24
- },
25
- },
26
- };
@@ -1,14 +0,0 @@
1
- /** @type {import('jest').Config} */
2
- module.exports = {
3
- transform: {
4
- "^.+\\.tsx?$": "@swc/jest",
5
- },
6
- moduleNameMapper: {
7
- "^src/(.*)$": "<rootDir>/src/$1",
8
- },
9
- testMatch: ["<rootDir>/src/**/*.test.{ts,tsx}"],
10
- testEnvironment: "node",
11
- globalSetup: "./src/setupTestEnv.ts",
12
- setupFilesAfterEnv: ["./src/setupTests.ts"],
13
- maxWorkers: 1,
14
- };
@@ -1,8 +0,0 @@
1
- {
2
- "codegenPlugins": ["joist-graphql-codegen"],
3
- "contextType": "Context@src/context",
4
- "entities": { "Author": { "tag": "a" }, "Book": { "tag": "b" } },
5
- "entitiesDirectory": "./src/entities",
6
- "idType": "tagged-string",
7
- "version": "0.0.0"
8
- }
@@ -1,38 +0,0 @@
1
- import {
2
- createCreatedAtFunction,
3
- createEntityTable,
4
- createUpdatedAtFunction,
5
- foreignKey,
6
- } from "joist-migration-utils";
7
- import { MigrationBuilder } from "node-pg-migrate";
8
-
9
- export function up(b: MigrationBuilder): void {
10
- createUpdatedAtFunction(b);
11
- createCreatedAtFunction(b);
12
-
13
- // Create flush_database function for test cleanup
14
- b.sql(`
15
- CREATE OR REPLACE FUNCTION flush_database() RETURNS void AS $$
16
- DECLARE
17
- tables CURSOR FOR
18
- SELECT tablename FROM pg_tables
19
- WHERE schemaname = 'public'
20
- AND tablename != 'pgmigrations';
21
- BEGIN
22
- FOR t IN tables LOOP
23
- EXECUTE 'TRUNCATE TABLE ' || quote_ident(t.tablename) || ' CASCADE';
24
- END LOOP;
25
- END;
26
- $$ LANGUAGE plpgsql;
27
- `);
28
-
29
- createEntityTable(b, "authors", {
30
- first_name: { type: "varchar(255)", notNull: true },
31
- last_name: { type: "varchar(255)", notNull: false },
32
- });
33
-
34
- createEntityTable(b, "books", {
35
- title: { type: "varchar(255)", notNull: true },
36
- author_id: foreignKey("authors", { notNull: true }),
37
- });
38
- }
@@ -1,41 +0,0 @@
1
- {
2
- "name": "graphql-template",
3
- "version": "0.1.0",
4
- "private": true,
5
- "scripts": {
6
- "build": "tsc",
7
- "start": "tsx src/server.ts",
8
- "dev": "tsx watch src/server.ts",
9
- "test": "env-cmd jest --runInBand",
10
- "codegen": "env-cmd yarn joist-codegen && yarn graphql-codegen",
11
- "graphql-codegen": "graphql-codegen --config graphql-codegen.js",
12
- "format": "prettier --write \"src/**/*.{ts,tsx,graphql}\""
13
- },
14
- "dependencies": {
15
- "@apollo/server": "^4.11.0",
16
- "@graphql-tools/graphql-file-loader": "^8.0.0",
17
- "@graphql-tools/load": "^8.0.0",
18
- "@graphql-tools/merge": "^9.0.0",
19
- "graphql": "^16.9.0",
20
- "joist-orm": "2.0.3-next.36",
21
- "knex": "^3.1.0",
22
- "pg": "^8.16.3"
23
- },
24
- "devDependencies": {
25
- "@graphql-codegen/cli": "^5.0.0",
26
- "@graphql-codegen/typescript": "^4.0.0",
27
- "@graphql-codegen/typescript-resolvers": "^4.0.0",
28
- "@homebound/graphql-typescript-possible-types": "^2.19.0",
29
- "@homebound/graphql-typescript-resolver-scaffolding": "^2.49.0",
30
- "@homebound/graphql-typescript-simple-resolvers": "^1.58.0",
31
- "@swc/core": "^1.13.0",
32
- "@swc/jest": "^0.2.39",
33
- "@types/jest": "^30.0.0",
34
- "@types/node": "^24.0.0",
35
- "env-cmd": "^11.0.0",
36
- "jest": "^30.0.0",
37
- "prettier": "^3.6.0",
38
- "tsx": "^4.20.0",
39
- "typescript": "^5.9.0"
40
- }
41
- }
@@ -1,9 +0,0 @@
1
- {
2
- "Author": ["books", "createdAt", "firstName", "id", "lastName", "updatedAt"],
3
- "Book": ["author", "createdAt", "id", "title", "updatedAt"],
4
- "Mutation": ["saveAuthor", "saveBook"],
5
- "SaveAuthorInput": ["firstName", "id", "lastName"],
6
- "SaveAuthorResult": ["author"],
7
- "SaveBookInput": ["authorId", "id", "title"],
8
- "SaveBookResult": ["book"]
9
- }
@@ -1,20 +0,0 @@
1
- extend type Mutation {
2
- saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
3
- }
4
-
5
- type Author {
6
- id: ID!
7
- firstName: String!
8
- lastName: String
9
- books: [Book!]!
10
- }
11
-
12
- input SaveAuthorInput {
13
- id: ID
14
- firstName: String
15
- lastName: String
16
- }
17
-
18
- type SaveAuthorResult {
19
- author: Author!
20
- }
@@ -1,19 +0,0 @@
1
- extend type Mutation {
2
- saveBook(input: SaveBookInput!): SaveBookResult!
3
- }
4
-
5
- type Book {
6
- id: ID!
7
- title: String!
8
- author: Author!
9
- }
10
-
11
- input SaveBookInput {
12
- id: ID
13
- title: String
14
- authorId: ID
15
- }
16
-
17
- type SaveBookResult {
18
- book: Book!
19
- }
File without changes
File without changes
@@ -1,12 +0,0 @@
1
- {
2
- "files": [
3
- "resolvers/author/authorResolvers.test.ts",
4
- "resolvers/author/authorResolvers.ts",
5
- "resolvers/author/saveAuthorMutation.test.ts",
6
- "resolvers/author/saveAuthorMutation.ts",
7
- "resolvers/book/bookResolvers.test.ts",
8
- "resolvers/book/bookResolvers.ts",
9
- "resolvers/book/saveBookMutation.test.ts",
10
- "resolvers/book/saveBookMutation.ts"
11
- ]
12
- }
@@ -1,14 +0,0 @@
1
- import { EntityManager, newPgConnectionConfig } from "joist-orm";
2
- import { PostgresDriver } from "joist-orm/pg";
3
- import { Pool } from "pg";
4
-
5
- export interface Context {
6
- pool: Pool;
7
- em: EntityManager;
8
- }
9
-
10
- export function newContext(): Context {
11
- const pool = new Pool(newPgConnectionConfig());
12
- const em = new EntityManager({}, new PostgresDriver(pool));
13
- return { em, pool };
14
- }
@@ -1,36 +0,0 @@
1
- import { newEm } from "../setupTests";
2
- import { newAuthor, newBook } from "./factories";
3
-
4
- describe("Author", () => {
5
- it("can create an author", async () => {
6
- const em = newEm();
7
- const author = newAuthor(em, { firstName: "John", lastName: "Doe" });
8
- await em.flush();
9
-
10
- const loaded = await em.load(author.constructor, author.id);
11
- expect(loaded).toMatchEntity({ firstName: "John", lastName: "Doe" });
12
- });
13
-
14
- it("has a full name", async () => {
15
- const em = newEm();
16
- const author = newAuthor(em, { firstName: "Jane", lastName: "Smith" });
17
- expect(author.fullName).toBe("Jane Smith");
18
- });
19
-
20
- it("handles missing last name in fullName", async () => {
21
- const em = newEm();
22
- const author = newAuthor(em, { firstName: "Jane" });
23
- expect(author.fullName).toBe("Jane");
24
- });
25
-
26
- it("can have books", async () => {
27
- const em = newEm();
28
- const author = newAuthor(em, { firstName: "Test", lastName: "Author" });
29
- const book = newBook(em, { title: "Test Book", author });
30
- await em.flush();
31
-
32
- const books = await author.books.load();
33
- expect(books).toHaveLength(1);
34
- expect(books[0]).toMatchEntity({ title: "Test Book" });
35
- });
36
- });
@@ -1,7 +0,0 @@
1
- import { AuthorCodegen } from "./codegen/AuthorCodegen";
2
-
3
- export class Author extends AuthorCodegen {
4
- get fullName(): string {
5
- return `${this.firstName} ${this.lastName || ""}`.trim();
6
- }
7
- }
@@ -1,3 +0,0 @@
1
- import { BookCodegen } from "./codegen/BookCodegen";
2
-
3
- export class Book extends BookCodegen {}
@@ -1,14 +0,0 @@
1
- // organize-imports-ignore
2
-
3
- // This file drives our import order to avoid undefined errors
4
- // when the subclasses extend the base classes, see:
5
- // https://medium.com/visual-development/how-to-fix-nasty-circular-dependency-issues-once-and-for-all-in-javascript-typescript-a04c987cf0de
6
-
7
- export * from "./codegen/AuthorCodegen";
8
- export * from "./codegen/BookCodegen";
9
- export * from "./Author";
10
- export * from "./Book";
11
-
12
- export * from "./factories/newAuthor";
13
- export * from "./factories/newBook";
14
- export * from "./codegen/metadata";
@@ -1,2 +0,0 @@
1
- export * from "./newAuthor";
2
- export * from "./newBook";
@@ -1,6 +0,0 @@
1
- import { EntityManager, FactoryOpts, newTestInstance } from "joist-orm";
2
- import { Author } from "../Author";
3
-
4
- export function newAuthor(em: EntityManager, opts?: FactoryOpts<Author>): Author {
5
- return newTestInstance(em, Author, opts);
6
- }
@@ -1,6 +0,0 @@
1
- import { EntityManager, FactoryOpts, newTestInstance } from "joist-orm";
2
- import { Book } from "../Book";
3
-
4
- export function newBook(em: EntityManager, opts?: FactoryOpts<Book>): Book {
5
- return newTestInstance(em, Book, opts);
6
- }
@@ -1,3 +0,0 @@
1
- export * from "./entities";
2
- export * from "./Author";
3
- export * from "./Book";
@@ -1,9 +0,0 @@
1
- declare namespace jest {
2
- type ContextOpts = Partial<import("./context").Context & import("./context").AppContext>;
3
- type itWithCtxFn = (ctx: import("./context").Context) => Promise<void>;
4
-
5
- interface It {
6
- withCtx(name: string, fn: itWithCtxFn): void;
7
- withCtx(name: string, opts: ContextOpts, fn: itWithCtxFn): void;
8
- }
9
- }
@@ -1,17 +0,0 @@
1
- import { newAuthor } from "src/entities";
2
- import { authorResolvers } from "src/resolvers/author/authorResolvers";
3
- import { makeRunObjectField, makeRunObjectFields } from "src/resolvers/testUtils";
4
-
5
- describe("authorResolvers", () => {
6
- it.withCtx("can return", async (ctx) => {
7
- const { em } = ctx;
8
- // Given a Author
9
- const a = newAuthor(em);
10
- // Then we can query it
11
- const result = await runFields(ctx, a, ["firstName", "lastName", "createdAt", "updatedAt"]);
12
- expect(result).toMatchEntity({});
13
- });
14
- });
15
-
16
- const runFields = makeRunObjectFields(authorResolvers);
17
- const runField = makeRunObjectField(authorResolvers);
@@ -1,5 +0,0 @@
1
- import { Author } from "src/entities";
2
- import type { AuthorResolvers } from "src/generated/graphql-types";
3
- import { entityResolver } from "src/resolvers/utils";
4
-
5
- export const authorResolvers: AuthorResolvers = { ...entityResolver(Author) };
@@ -1,13 +0,0 @@
1
- import { saveAuthor } from "src/resolvers/author/saveAuthorMutation";
2
- import { makeRunInputMutation } from "src/resolvers/testUtils";
3
-
4
- describe("saveAuthor", () => {
5
- it.withCtx("can create", async (ctx) => {
6
- const result = await runSave(ctx, () => ({
7
- firstName: "Test",
8
- }));
9
- expect(result).toBeDefined();
10
- });
11
- });
12
-
13
- const runSave = makeRunInputMutation(saveAuthor);
@@ -1,9 +0,0 @@
1
- import { Author } from "src/entities";
2
- import type { MutationResolvers } from "src/generated/graphql-types";
3
- import { saveEntity } from "src/resolvers/utils";
4
-
5
- export const saveAuthor: Pick<MutationResolvers, "saveAuthor"> = {
6
- async saveAuthor(_, args, ctx) {
7
- return { author: await saveEntity(ctx, Author, args.input) };
8
- },
9
- };
@@ -1,17 +0,0 @@
1
- import { newBook } from "src/entities";
2
- import { bookResolvers } from "src/resolvers/book/bookResolvers";
3
- import { makeRunObjectField, makeRunObjectFields } from "src/resolvers/testUtils";
4
-
5
- describe("bookResolvers", () => {
6
- it.withCtx("can return", async (ctx) => {
7
- const { em } = ctx;
8
- // Given a Book
9
- const b = newBook(em);
10
- // Then we can query it
11
- const result = await runFields(ctx, b, ["title", "createdAt", "updatedAt"]);
12
- expect(result).toMatchEntity({});
13
- });
14
- });
15
-
16
- const runFields = makeRunObjectFields(bookResolvers);
17
- const runField = makeRunObjectField(bookResolvers);
@@ -1,5 +0,0 @@
1
- import { Book } from "src/entities";
2
- import type { BookResolvers } from "src/generated/graphql-types";
3
- import { entityResolver } from "src/resolvers/utils";
4
-
5
- export const bookResolvers: BookResolvers = { ...entityResolver(Book) };
@@ -1,16 +0,0 @@
1
- import { newAuthor } from "src/entities/index";
2
- import { saveBook } from "src/resolvers/book/saveBookMutation";
3
- import { makeRunInputMutation } from "src/resolvers/testUtils";
4
-
5
- describe("saveBook", () => {
6
- it.withCtx("can create", async (ctx) => {
7
- const a = newAuthor(ctx.em);
8
- const result = await runSave(ctx, () => ({
9
- title: "Test Book",
10
- authorId: a.id,
11
- }));
12
- expect(result).toBeDefined();
13
- });
14
- });
15
-
16
- const runSave = makeRunInputMutation(saveBook);
@@ -1,9 +0,0 @@
1
- import { Book } from "src/entities";
2
- import type { MutationResolvers } from "src/generated/graphql-types";
3
- import { saveEntity } from "src/resolvers/utils";
4
-
5
- export const saveBook: Pick<MutationResolvers, "saveBook"> = {
6
- async saveBook(_, args, ctx) {
7
- return { book: await saveEntity(ctx, Book, args.input) };
8
- },
9
- };
@@ -1,5 +0,0 @@
1
- import type { Resolvers } from "src/generated/graphql-types";
2
-
3
- type EnumDetails = never;
4
-
5
- export const enumResolvers: Pick<Resolvers, EnumDetails> = {};
@@ -1,15 +0,0 @@
1
- import { authorResolvers } from "./authorResolvers";
2
- import { bookResolvers } from "./bookResolvers";
3
-
4
- export const resolvers = {
5
- Query: {
6
- ...authorResolvers.Query,
7
- ...bookResolvers.Query,
8
- },
9
- Mutation: {
10
- ...authorResolvers.Mutation,
11
- ...bookResolvers.Mutation,
12
- },
13
- Author: authorResolvers.Author,
14
- Book: bookResolvers.Book,
15
- };
@@ -1,7 +0,0 @@
1
- import type { MutationResolvers } from "src/generated/graphql-types";
2
- import { saveAuthor } from "src/resolvers/author/saveAuthorMutation";
3
- import { saveBook } from "src/resolvers/book/saveBookMutation";
4
-
5
- // This file is auto-generated
6
-
7
- export const mutationResolvers: MutationResolvers = { ...saveAuthor, ...saveBook };
@@ -1,6 +0,0 @@
1
- import { authorResolvers } from "src/resolvers/author/authorResolvers";
2
- import { bookResolvers } from "src/resolvers/book/bookResolvers";
3
-
4
- // This file is auto-generated
5
-
6
- export const objectResolvers = { Author: authorResolvers, Book: bookResolvers };
@@ -1,10 +0,0 @@
1
- import {
2
- makeMakeRunInputMutation,
3
- makeMakeRunObjectField,
4
- makeMakeRunObjectFields,
5
- } from "joist-graphql-resolver-utils/tests";
6
- import { run } from "joist-orm/tests";
7
-
8
- export const makeRunObjectField = makeMakeRunObjectField(run);
9
- export const makeRunObjectFields = makeMakeRunObjectFields(run);
10
- export const makeRunInputMutation = makeMakeRunInputMutation(run);
@@ -1 +0,0 @@
1
- export { entityResolver, saveEntities, saveEntity } from "joist-orm/graphql";
@@ -1,37 +0,0 @@
1
- import { ApolloServer } from "@apollo/server";
2
- import { startStandaloneServer } from "@apollo/server/standalone";
3
- import { loadSchemaSync } from "@graphql-tools/load";
4
- import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader";
5
- import { EntityManager } from "joist-orm";
6
- import { newPgConnectionConfig } from "joist-orm/pg";
7
- import knex from "knex";
8
- import path from "path";
9
- import { Context } from "./context";
10
- import { entities } from "./entities";
11
- import { resolvers } from "./resolvers";
12
-
13
- const typeDefs = loadSchemaSync(path.join(__dirname, "./**/*.graphql"), {
14
- loaders: [new GraphQLFileLoader()],
15
- });
16
-
17
- async function main() {
18
- const config = newPgConnectionConfig();
19
- const db = knex({ client: "pg", connection: config });
20
-
21
- const server = new ApolloServer<Context>({
22
- typeDefs,
23
- resolvers,
24
- });
25
-
26
- const { url } = await startStandaloneServer(server, {
27
- listen: { port: parseInt(process.env.PORT || "4000") },
28
- context: async () => {
29
- const em = new EntityManager({ entities, driver: db }, {});
30
- return { em };
31
- },
32
- });
33
-
34
- console.log(`🚀 Server ready at ${url}`);
35
- }
36
-
37
- main().catch(console.error);
@@ -1,17 +0,0 @@
1
- import { createTestContext } from "src/setupTests";
2
-
3
- it.withCtx = (name: string, fnOrOpts: jest.itWithCtxFn | jest.ContextOpts, maybeFn?: jest.itWithCtxFn) => {
4
- const fn: jest.itWithCtxFn = typeof fnOrOpts === "function" ? fnOrOpts : maybeFn!;
5
- const opts: jest.ContextOpts = typeof fnOrOpts === "function" ? {} : fnOrOpts;
6
- it(name, async () => fn(await createTestContext(opts)));
7
- };
8
-
9
- it.skip.withCtx = (name: string, fnOrOpts: jest.itWithCtxFn | jest.ContextOpts, maybeFn?: jest.itWithCtxFn) =>
10
- it.skip(name, () => {});
11
- it.only.withCtx = (name: string, fnOrOpts: jest.itWithCtxFn | jest.ContextOpts, maybeFn?: jest.itWithCtxFn) => {
12
- const fn: jest.itWithCtxFn = typeof fnOrOpts === "function" ? fnOrOpts : maybeFn!;
13
- const opts: jest.ContextOpts = typeof fnOrOpts === "function" ? {} : fnOrOpts;
14
- it.only(name, async () => fn(await createTestContext(opts)));
15
- };
16
- xit.withCtx = it.skip.withCtx;
17
- fit.withCtx = it.only.withCtx;
@@ -1,5 +0,0 @@
1
- import { GetEnvVars } from "env-cmd";
2
-
3
- export default async function globalSetup() {
4
- Object.entries(await GetEnvVars()).forEach(([key, value]) => (process.env[key] = value));
5
- }
@@ -1,37 +0,0 @@
1
- import expect from "expect";
2
- import { newPgConnectionConfig } from "joist-orm";
3
- import { PostgresDriver } from "joist-orm/pg";
4
- import { toMatchEntity } from "joist-orm/tests";
5
- import pg from "pg";
6
- import "src/setupIt";
7
- import { Context } from "./context";
8
- import { EntityManager } from "./entities";
9
-
10
- expect.extend({ toMatchEntity });
11
-
12
- let pool: pg.Pool;
13
-
14
- beforeAll(async () => {
15
- pool = new pg.Pool(newPgConnectionConfig());
16
- });
17
-
18
- beforeEach(async () => {
19
- await pool.query("select flush_database()");
20
- });
21
-
22
- afterAll(async () => {
23
- await pool.end();
24
- });
25
-
26
- export function newEm(): EntityManager {
27
- const driver = new PostgresDriver(pool);
28
- const ctx = { pool, em: null as any } satisfies Context;
29
- const em = new EntityManager(ctx, driver);
30
- Object.assign(ctx, { em });
31
- return em;
32
- }
33
-
34
- export async function createTestContext(opts: {}): Promise<Context> {
35
- const em = newEm();
36
- return em.ctx;
37
- }
@@ -1,23 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "nodenext",
5
- "lib": ["ES2022"],
6
- "moduleResolution": "nodenext",
7
- "esModuleInterop": true,
8
- "strict": true,
9
- "skipLibCheck": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "declaration": true,
12
- "declarationMap": true,
13
- "sourceMap": true,
14
- "outDir": "./build",
15
- "rootDir": "./src",
16
- "baseUrl": "./src",
17
- "paths": {
18
- "src/*": ["./*"]
19
- }
20
- },
21
- "include": ["src"],
22
- "exclude": ["node_modules", "build"]
23
- }