@graphql-codegen/typescript-operations 4.6.0-alpha-20250324100136-f747362f2ef0b3a95f2b0724af9447004c58a212 → 4.6.0-alpha-20250326082838-591d10d3f7173174c5ba03cbf8903a4f2fdb7901
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/cjs/index.js +5 -5
- package/esm/index.js +5 -5
- package/package.json +3 -3
- package/typings/config.d.cts +3 -3
- package/typings/config.d.ts +3 -3
package/cjs/index.js
CHANGED
|
@@ -29,10 +29,10 @@ const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common"
|
|
|
29
29
|
const graphql_1 = require("graphql");
|
|
30
30
|
const visitor_js_1 = require("./visitor.js");
|
|
31
31
|
Object.defineProperty(exports, "TypeScriptDocumentsVisitor", { enumerable: true, get: function () { return visitor_js_1.TypeScriptDocumentsVisitor; } });
|
|
32
|
-
const plugin = async (
|
|
33
|
-
const
|
|
32
|
+
const plugin = async (inputSchema, rawDocuments, config) => {
|
|
33
|
+
const schema = config.nullability?.errorHandlingClient ? await semanticToStrict(inputSchema) : inputSchema;
|
|
34
34
|
const documents = config.flattenGeneratedTypes
|
|
35
|
-
? (0, visitor_plugin_common_1.optimizeOperations)(
|
|
35
|
+
? (0, visitor_plugin_common_1.optimizeOperations)(schema, rawDocuments, {
|
|
36
36
|
includeFragments: config.flattenGeneratedTypesIncludeFragments,
|
|
37
37
|
})
|
|
38
38
|
: rawDocuments;
|
|
@@ -46,7 +46,7 @@ const plugin = async (schema, rawDocuments, config) => {
|
|
|
46
46
|
})),
|
|
47
47
|
...(config.externalFragments || []),
|
|
48
48
|
];
|
|
49
|
-
const visitor = new visitor_js_1.TypeScriptDocumentsVisitor(
|
|
49
|
+
const visitor = new visitor_js_1.TypeScriptDocumentsVisitor(schema, config, allFragments);
|
|
50
50
|
const visitorResult = (0, plugin_helpers_1.oldVisit)(allAst, {
|
|
51
51
|
leave: visitor,
|
|
52
52
|
});
|
|
@@ -78,6 +78,6 @@ const semanticToStrict = async (schema) => {
|
|
|
78
78
|
return sock.semanticToStrict(schema);
|
|
79
79
|
}
|
|
80
80
|
catch {
|
|
81
|
-
throw new Error("To use the `
|
|
81
|
+
throw new Error("To use the `nullability.errorHandlingClient` option, you must install the 'graphql-sock' package.");
|
|
82
82
|
}
|
|
83
83
|
};
|
package/esm/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import { oldVisit } from '@graphql-codegen/plugin-helpers';
|
|
|
2
2
|
import { optimizeOperations } from '@graphql-codegen/visitor-plugin-common';
|
|
3
3
|
import { concatAST, Kind } from 'graphql';
|
|
4
4
|
import { TypeScriptDocumentsVisitor } from './visitor.js';
|
|
5
|
-
export const plugin = async (
|
|
6
|
-
const
|
|
5
|
+
export const plugin = async (inputSchema, rawDocuments, config) => {
|
|
6
|
+
const schema = config.nullability?.errorHandlingClient ? await semanticToStrict(inputSchema) : inputSchema;
|
|
7
7
|
const documents = config.flattenGeneratedTypes
|
|
8
|
-
? optimizeOperations(
|
|
8
|
+
? optimizeOperations(schema, rawDocuments, {
|
|
9
9
|
includeFragments: config.flattenGeneratedTypesIncludeFragments,
|
|
10
10
|
})
|
|
11
11
|
: rawDocuments;
|
|
@@ -19,7 +19,7 @@ export const plugin = async (schema, rawDocuments, config) => {
|
|
|
19
19
|
})),
|
|
20
20
|
...(config.externalFragments || []),
|
|
21
21
|
];
|
|
22
|
-
const visitor = new TypeScriptDocumentsVisitor(
|
|
22
|
+
const visitor = new TypeScriptDocumentsVisitor(schema, config, allFragments);
|
|
23
23
|
const visitorResult = oldVisit(allAst, {
|
|
24
24
|
leave: visitor,
|
|
25
25
|
});
|
|
@@ -51,6 +51,6 @@ const semanticToStrict = async (schema) => {
|
|
|
51
51
|
return sock.semanticToStrict(schema);
|
|
52
52
|
}
|
|
53
53
|
catch {
|
|
54
|
-
throw new Error("To use the `
|
|
54
|
+
throw new Error("To use the `nullability.errorHandlingClient` option, you must install the 'graphql-sock' package.");
|
|
55
55
|
}
|
|
56
56
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-operations",
|
|
3
|
-
"version": "4.6.0-alpha-
|
|
3
|
+
"version": "4.6.0-alpha-20250326082838-591d10d3f7173174c5ba03cbf8903a4f2fdb7901",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating TypeScript types for GraphQL queries, mutations, subscriptions and fragments",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@graphql-codegen/plugin-helpers": "^5.1.0",
|
|
11
|
-
"@graphql-codegen/typescript": "4.1.6-alpha-
|
|
12
|
-
"@graphql-codegen/visitor-plugin-common": "5.8.0-alpha-
|
|
11
|
+
"@graphql-codegen/typescript": "4.1.6-alpha-20250326082838-591d10d3f7173174c5ba03cbf8903a4f2fdb7901",
|
|
12
|
+
"@graphql-codegen/visitor-plugin-common": "5.8.0-alpha-20250326082838-591d10d3f7173174c5ba03cbf8903a4f2fdb7901",
|
|
13
13
|
"auto-bind": "~4.0.0",
|
|
14
14
|
"tslib": "~2.6.0"
|
|
15
15
|
},
|
package/typings/config.d.cts
CHANGED
|
@@ -288,7 +288,7 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
288
288
|
*/
|
|
289
289
|
allowUndefinedQueryVariables?: boolean;
|
|
290
290
|
/**
|
|
291
|
-
* @description Options related to
|
|
291
|
+
* @description Options related to handling nullability
|
|
292
292
|
* @exampleMarkdown
|
|
293
293
|
* ## `errorHandlingClient`
|
|
294
294
|
* When using error handling clients, a semantic non-nullable field can never be `null`.
|
|
@@ -311,7 +311,7 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
311
311
|
* 'path/to/file.ts': {
|
|
312
312
|
* plugins: ['typescript', 'typescript-operations'],
|
|
313
313
|
* config: {
|
|
314
|
-
*
|
|
314
|
+
* nullability: {
|
|
315
315
|
* errorHandlingClient: true
|
|
316
316
|
* }
|
|
317
317
|
* },
|
|
@@ -321,7 +321,7 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
321
321
|
* export default config;
|
|
322
322
|
* ```
|
|
323
323
|
*/
|
|
324
|
-
|
|
324
|
+
nullability?: {
|
|
325
325
|
errorHandlingClient: boolean;
|
|
326
326
|
};
|
|
327
327
|
}
|
package/typings/config.d.ts
CHANGED
|
@@ -288,7 +288,7 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
288
288
|
*/
|
|
289
289
|
allowUndefinedQueryVariables?: boolean;
|
|
290
290
|
/**
|
|
291
|
-
* @description Options related to
|
|
291
|
+
* @description Options related to handling nullability
|
|
292
292
|
* @exampleMarkdown
|
|
293
293
|
* ## `errorHandlingClient`
|
|
294
294
|
* When using error handling clients, a semantic non-nullable field can never be `null`.
|
|
@@ -311,7 +311,7 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
311
311
|
* 'path/to/file.ts': {
|
|
312
312
|
* plugins: ['typescript', 'typescript-operations'],
|
|
313
313
|
* config: {
|
|
314
|
-
*
|
|
314
|
+
* nullability: {
|
|
315
315
|
* errorHandlingClient: true
|
|
316
316
|
* }
|
|
317
317
|
* },
|
|
@@ -321,7 +321,7 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig {
|
|
|
321
321
|
* export default config;
|
|
322
322
|
* ```
|
|
323
323
|
*/
|
|
324
|
-
|
|
324
|
+
nullability?: {
|
|
325
325
|
errorHandlingClient: boolean;
|
|
326
326
|
};
|
|
327
327
|
}
|