@axinom/mosaic-graphql-codegen-plugins 0.7.0-rc.14 → 0.7.0-rc.16

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 CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@axinom/mosaic-graphql-codegen-plugins",
3
- "version": "0.7.0-rc.14",
3
+ "version": "0.7.0-rc.16",
4
4
  "description": "Library of graphql-codegen plugins for Mosaic workflows",
5
5
  "scripts": {
6
6
  "dev": "tsc -w",
7
7
  "clean": "rimraf dist",
8
8
  "build": "yarn clean && tsc --project tsconfig.build.json",
9
9
  "build:ci": "yarn workspaces focus && yarn build",
10
- "test": "jest --silent",
11
- "test:watch": "jest --watch",
10
+ "test": "vitest run --silent",
11
+ "test:watch": "vitest watch",
12
+ "test:cov": "vitest run --coverage --silent",
12
13
  "lint": "eslint . --ext .ts,.tsx,.js --color --cache"
13
14
  },
14
15
  "author": "Axinom",
@@ -33,10 +34,10 @@
33
34
  "devDependencies": {
34
35
  "@graphql-codegen/plugin-helpers": "^5.1.1",
35
36
  "graphql": "^15.0.0",
36
- "jest": "^29",
37
37
  "rimraf": "^3.0.2",
38
38
  "ts-node": "^10.9.1",
39
- "typescript": "^5.9.3"
39
+ "typescript": "^5.9.3",
40
+ "vitest": "^4.0.18"
40
41
  },
41
42
  "peerDependencies": {
42
43
  "graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0"
@@ -44,5 +45,5 @@
44
45
  "publishConfig": {
45
46
  "access": "public"
46
47
  },
47
- "gitHead": "69412d27b39302534935fe636fb07b1d4468becb"
48
+ "gitHead": "61cc0e626bb816beee81d16b31c46f1d2a13844d"
48
49
  }
@@ -3,9 +3,11 @@ import {
3
3
  GraphQLList,
4
4
  GraphQLNonNull,
5
5
  GraphQLObjectType,
6
+ GraphQLScalarType,
6
7
  GraphQLSchema,
7
8
  GraphQLString,
8
9
  } from 'graphql';
10
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
9
11
  import { BulkEditPluginConfig, plugin } from './generate-bulk-edit-ui-config';
10
12
 
11
13
  describe('generate-bulk-edit-ui-config plugin', () => {
@@ -335,11 +337,25 @@ describe('generate-bulk-edit-ui-config plugin', () => {
335
337
  });
336
338
 
337
339
  it('should handle errors gracefully and fall back to toString()', () => {
338
- // Create a mock field type that will throw an error when accessing ofType
340
+ // Create a valid GraphQL input type that throws when "ofType" is accessed.
341
+ // This guarantees resolveFields() enters its catch-path.
342
+ const ProblematicScalarType = new GraphQLScalarType({
343
+ name: 'ProblematicScalar',
344
+ serialize: (value) => value,
345
+ parseValue: (value) => value,
346
+ parseLiteral: () => null,
347
+ });
348
+
349
+ Object.defineProperty(ProblematicScalarType, 'ofType', {
350
+ get: () => {
351
+ throw new Error('Synthetic ofType access error');
352
+ },
353
+ });
354
+
339
355
  const ProblematicInputType = new GraphQLInputObjectType({
340
356
  name: 'ProblematicInput',
341
357
  fields: {
342
- normalField: { type: GraphQLString },
358
+ normalField: { type: ProblematicScalarType },
343
359
  },
344
360
  });
345
361
 
@@ -365,14 +381,22 @@ describe('generate-bulk-edit-ui-config plugin', () => {
365
381
  });
366
382
 
367
383
  // Spy on console.warn to verify it's called if needed
368
- const consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation();
384
+ const consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {
385
+ // no-op
386
+ });
369
387
 
370
388
  const result = plugin(schemaWithProblematic, [], {}) as string;
371
389
 
372
390
  // Should still generate config even if there's an error
373
391
  expect(result).toContain('BulkEditProblematicFormFieldsConfig');
374
392
  expect(result).toContain('"normalField"');
375
- expect(result).toContain('"type": "String"');
393
+ expect(result).toContain('"type": "ProblematicScalar"');
394
+ expect(consoleWarnSpy).toHaveBeenCalledWith(
395
+ expect.stringContaining(
396
+ 'Warning: Unable to resolve type structure for field "normalField".',
397
+ ),
398
+ expect.any(Error),
399
+ );
376
400
 
377
401
  // Restore console.warn
378
402
  consoleWarnSpy.mockRestore();
@@ -1,4 +1,5 @@
1
1
  import { buildSchema } from 'graphql';
2
+ import { describe, expect, it } from 'vitest';
2
3
  import { plugin } from './generate-enum-comments';
3
4
 
4
5
  describe('generate-enum-comments plugin', () => {