create-joist-app 1.0.6 → 1.0.7
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.
- package/package.json +1 -1
- package/templates/graphql/src/context.ts +1 -1
- package/templates/graphql/src/entities/Author.test.ts +1 -4
- package/templates/graphql/src/entities/factories/newAuthor.ts +3 -3
- package/templates/graphql/src/entities/factories/newBook.ts +3 -3
- package/templates/graphql/src/resolvers/author/authorResolvers.test.ts +1 -1
- package/templates/graphql/src/resolvers/book/bookResolvers.test.ts +1 -1
- package/templates/graphql/src/resolvers/index.ts +6 -12
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { EntityManager } from "joist-orm";
|
|
1
2
|
import { newPgConnectionConfig } from "joist-orm";
|
|
2
3
|
import { PostgresDriver } from "joist-orm/pg";
|
|
3
4
|
import { Pool } from "pg";
|
|
4
|
-
import type { EntityManager } from "./entities";
|
|
5
5
|
|
|
6
6
|
/** The app-wide global context, created once on boot & shared across all requests. */
|
|
7
7
|
export interface AppContext {
|
|
@@ -4,11 +4,8 @@ import { newAuthor, newBook } from "./factories";
|
|
|
4
4
|
describe("Author", () => {
|
|
5
5
|
it("can create an author", async () => {
|
|
6
6
|
const em = newEm();
|
|
7
|
-
|
|
7
|
+
newAuthor(em, { firstName: "John", lastName: "Doe" });
|
|
8
8
|
await em.flush();
|
|
9
|
-
|
|
10
|
-
const loaded = await em.load(author.constructor, author.id);
|
|
11
|
-
expect(loaded).toMatchEntity({ firstName: "John", lastName: "Doe" });
|
|
12
9
|
});
|
|
13
10
|
|
|
14
11
|
it("has a full name", async () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EntityManager, FactoryOpts, newTestInstance } from "joist-orm";
|
|
1
|
+
import { type DeepNew, EntityManager, FactoryOpts, newTestInstance } from "joist-orm";
|
|
2
2
|
import { Author } from "../Author";
|
|
3
3
|
|
|
4
|
-
export function newAuthor(em: EntityManager, opts?: FactoryOpts<Author>): Author {
|
|
5
|
-
return newTestInstance(em, Author, opts)
|
|
4
|
+
export function newAuthor(em: EntityManager, opts?: FactoryOpts<Author>): DeepNew<Author> {
|
|
5
|
+
return newTestInstance(em, Author, opts) as DeepNew<Author>;
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EntityManager, FactoryOpts, newTestInstance } from "joist-orm";
|
|
1
|
+
import { type DeepNew, EntityManager, FactoryOpts, newTestInstance } from "joist-orm";
|
|
2
2
|
import { Book } from "../Book";
|
|
3
3
|
|
|
4
|
-
export function newBook(em: EntityManager, opts?: FactoryOpts<Book>): Book {
|
|
5
|
-
return newTestInstance(em, Book, opts)
|
|
4
|
+
export function newBook(em: EntityManager, opts?: FactoryOpts<Book>): DeepNew<Book> {
|
|
5
|
+
return newTestInstance(em, Book, opts) as DeepNew<Book>;
|
|
6
6
|
}
|
|
@@ -8,7 +8,7 @@ describe("authorResolvers", () => {
|
|
|
8
8
|
// Given a Author
|
|
9
9
|
const a = newAuthor(em);
|
|
10
10
|
// Then we can query it
|
|
11
|
-
const result = await runFields(ctx, a, ["firstName", "lastName"
|
|
11
|
+
const result = await runFields(ctx, a, ["firstName", "lastName"]);
|
|
12
12
|
expect(result).toMatchEntity({});
|
|
13
13
|
});
|
|
14
14
|
});
|
|
@@ -8,7 +8,7 @@ describe("bookResolvers", () => {
|
|
|
8
8
|
// Given a Book
|
|
9
9
|
const b = newBook(em);
|
|
10
10
|
// Then we can query it
|
|
11
|
-
const result = await runFields(ctx, b, ["title"
|
|
11
|
+
const result = await runFields(ctx, b, ["title"]);
|
|
12
12
|
expect(result).toMatchEntity({});
|
|
13
13
|
});
|
|
14
14
|
});
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { enumResolvers } from "src/resolvers/enumResolvers";
|
|
2
|
+
import { mutationResolvers } from "src/resolvers/mutations";
|
|
3
|
+
import { objectResolvers } from "src/resolvers/objects";
|
|
3
4
|
|
|
4
5
|
export const resolvers = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
Mutation: {
|
|
10
|
-
...authorResolvers.Mutation,
|
|
11
|
-
...bookResolvers.Mutation,
|
|
12
|
-
},
|
|
13
|
-
Author: authorResolvers.Author,
|
|
14
|
-
Book: bookResolvers.Book,
|
|
6
|
+
...enumResolvers,
|
|
7
|
+
...objectResolvers,
|
|
8
|
+
Mutation: mutationResolvers,
|
|
15
9
|
};
|