joist-graphql-codegen 1.10.2 → 1.10.3

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.
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const generateGraphqlCodegen_1 = require("./generateGraphqlCodegen");
4
4
  describe("generateGraphqlCodegen", () => {
5
- it("creates a json file", () => {
5
+ it("creates a json file", async () => {
6
6
  const entities = [];
7
7
  const enums = {};
8
8
  const file = (0, generateGraphqlCodegen_1.generateGraphqlCodegen)(entities, enums);
9
- expect(file.contents.toString()).toMatchInlineSnapshot(`
9
+ expect(await file.contents.toStringWithImports()).toMatchInlineSnapshot(`
10
10
  "const mappers = {};
11
11
 
12
12
  const enumValues = {};
@@ -1 +1 @@
1
- {"version":3,"file":"generateGraphqlCodegen.test.js","sourceRoot":"","sources":["../src/generateGraphqlCodegen.test.ts"],"names":[],"mappings":";;AACA,qEAAkE;AAElE,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE;QAC7B,MAAM,QAAQ,GAAuB,EAAE,CAAC;QACxC,MAAM,KAAK,GAAiB,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,IAAA,+CAAsB,EAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACrD,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;;;KAOtD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"generateGraphqlCodegen.test.js","sourceRoot":"","sources":["../src/generateGraphqlCodegen.test.ts"],"names":[],"mappings":";;AAEA,qEAAkE;AAElE,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,EAAE,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,QAAQ,GAAuB,EAAE,CAAC;QACxC,MAAM,KAAK,GAAiB,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,IAAA,+CAAsB,EAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACrD,MAAM,CAAC,MAAO,IAAI,CAAC,QAAiB,CAAC,mBAAmB,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;;;KAOjF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -16,8 +16,8 @@ const history_1 = require("./history");
16
16
  async function generateGraphqlSchemaFiles(fs, entities) {
17
17
  // Generate all of the "ideal" fields based solely on the domain model
18
18
  const fields = [
19
- ...createEntityFields(entities),
20
19
  ...createSaveMutation(entities),
20
+ ...createEntityFields(entities),
21
21
  ...createSaveEntityInputFields(entities),
22
22
  ...createSaveEntityResultFields(entities),
23
23
  ];
@@ -15,13 +15,13 @@ describe("generateGraphqlSchemaFiles", () => {
15
15
  await (0, generateGraphqlSchemaFiles_1.generateGraphqlSchemaFiles)(fs, entities);
16
16
  // We now have a graphql file
17
17
  expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
18
- "type Author {
19
- id: ID!
20
- }
21
-
22
- extend type Mutation {
18
+ "extend type Mutation {
23
19
  saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
24
20
  }
21
+
22
+ type Author {
23
+ id: ID!
24
+ }
25
25
 
26
26
  input SaveAuthorInput {
27
27
  id: ID
@@ -220,16 +220,16 @@ describe("generateGraphqlSchemaFiles", () => {
220
220
  await (0, generateGraphqlSchemaFiles_1.generateGraphqlSchemaFiles)(fs, entities);
221
221
  // Then the input does not have the createdAt field
222
222
  expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
223
- "type Author {
223
+ "extend type Mutation {
224
+ saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
225
+ }
226
+
227
+ type Author {
224
228
  id: ID!
225
229
  firstName: String!
226
230
  createdAt: String!
227
231
  }
228
232
 
229
- extend type Mutation {
230
- saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
231
- }
232
-
233
233
  input SaveAuthorInput {
234
234
  id: ID
235
235
  firstName: String
@@ -260,17 +260,17 @@ describe("generateGraphqlSchemaFiles", () => {
260
260
  await (0, generateGraphqlSchemaFiles_1.generateGraphqlSchemaFiles)(fs, entities);
261
261
  // Then the input has both both types of fields as appropriate
262
262
  expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
263
- "type Author {
263
+ "extend type Mutation {
264
+ saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
265
+ }
266
+
267
+ type Author {
264
268
  id: ID!
265
269
  firstName: String!
266
270
  createdAt: DateTime!
267
271
  startDate: Date!
268
272
  }
269
273
 
270
- extend type Mutation {
271
- saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
272
- }
273
-
274
274
  input SaveAuthorInput {
275
275
  id: ID
276
276
  firstName: String
@@ -297,13 +297,13 @@ type SaveAuthorResult {
297
297
  await (0, generateGraphqlSchemaFiles_1.generateGraphqlSchemaFiles)(fs, entities);
298
298
  // Then the input has both both types of fields as appropriate
299
299
  expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
300
- "type Author {
301
- id: ID!
302
- color: ColorDetail!
300
+ "extend type Mutation {
301
+ saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
303
302
  }
304
303
 
305
- extend type Mutation {
306
- saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
304
+ type Author {
305
+ id: ID!
306
+ color: ColorDetail!
307
307
  }
308
308
 
309
309
  input SaveAuthorInput {
@@ -330,13 +330,13 @@ type SaveAuthorResult {
330
330
  await (0, generateGraphqlSchemaFiles_1.generateGraphqlSchemaFiles)(fs, entities);
331
331
  // Then the input has both both types of fields as appropriate
332
332
  expect(await fs.load("author.graphql")).toMatchInlineSnapshot(`
333
- "type Author {
334
- id: ID!
335
- color: [Color!]!
333
+ "extend type Mutation {
334
+ saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
336
335
  }
337
336
 
338
- extend type Mutation {
339
- saveAuthor(input: SaveAuthorInput!): SaveAuthorResult!
337
+ type Author {
338
+ id: ID!
339
+ color: [Color!]!
340
340
  }
341
341
 
342
342
  input SaveAuthorInput {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joist-graphql-codegen",
3
- "version": "1.10.2",
3
+ "version": "1.10.3",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,7 +10,8 @@
10
10
  "main": "build/index.js",
11
11
  "types": "build/index.d.ts",
12
12
  "scripts": {
13
- "format": "prettier --write '{schema,migrations,src}/**/*.{ts,js,tsx,jsx,graphql}'"
13
+ "format": "prettier --write '{schema,migrations,src}/**/*.{ts,js,tsx,jsx,graphql}'",
14
+ "test": "jest"
14
15
  },
15
16
  "files": [
16
17
  "build"
@@ -19,8 +20,8 @@
19
20
  "change-case": "^4.1.1",
20
21
  "graphql": "^15.3.0",
21
22
  "is-plain-object": "^3.0.1",
22
- "joist-codegen": "1.10.2",
23
- "joist-utils": "1.10.2",
23
+ "joist-codegen": "1.10.3",
24
+ "joist-utils": "1.10.3",
24
25
  "pluralize": "^8.0.0",
25
26
  "ts-poet": "^4.8.0"
26
27
  },