@axinom/mosaic-graphql-codegen-plugins 0.7.0-rc.5 → 0.8.0-rc.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.
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-graphql-codegen-plugins",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-rc.0",
|
|
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": "
|
|
11
|
-
"test: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.
|
|
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": "
|
|
48
|
+
"gitHead": "fc3c189f45b1e7bb1af248119e35ba80ddce9a50"
|
|
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
|
|
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:
|
|
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 =
|
|
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": "
|
|
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();
|