@graphql-codegen/typescript 6.0.0-alpha-20260107121718-414f6b05f03eb30da88b64cf2059f9ec698fa200 → 6.0.0-alpha-20260107125844-590bbacbf920ee5f5f207f26f318613d135b0cdb
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/visitor.js +2 -27
- package/esm/visitor.js +1 -26
- package/package.json +2 -2
- package/typings/visitor.d.cts +0 -8
- package/typings/visitor.d.ts +0 -8
package/cjs/visitor.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TsVisitor =
|
|
3
|
+
exports.TsVisitor = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
|
|
6
6
|
const auto_bind_1 = tslib_1.__importDefault(require("auto-bind"));
|
|
7
7
|
const graphql_1 = require("graphql");
|
|
8
8
|
const typescript_variables_to_object_js_1 = require("./typescript-variables-to-object.js");
|
|
9
|
-
exports.MAKE_OPTIONAL_SIGNATURE = `type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };`;
|
|
10
|
-
exports.MAKE_MAYBE_SIGNATURE = `type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };`;
|
|
11
|
-
exports.MAKE_EMPTY_SIGNATURE = `type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };`;
|
|
12
|
-
exports.MAKE_INCREMENTAL_SIGNATURE = `type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };`;
|
|
13
9
|
class TsVisitor extends visitor_plugin_common_1.BaseTypesVisitor {
|
|
14
10
|
constructor(schema, pluginConfig, additionalConfig = {}) {
|
|
15
11
|
super(schema, pluginConfig, {
|
|
@@ -80,14 +76,7 @@ class TsVisitor extends visitor_plugin_common_1.BaseTypesVisitor {
|
|
|
80
76
|
getWrapperDefinitions() {
|
|
81
77
|
if (this.config.onlyEnums)
|
|
82
78
|
return [];
|
|
83
|
-
const definitions = [
|
|
84
|
-
this.getMaybeValue(),
|
|
85
|
-
this.getInputMaybeValue(),
|
|
86
|
-
this.getMakeOptionalDefinition(),
|
|
87
|
-
this.getMakeMaybeDefinition(),
|
|
88
|
-
this.getMakeEmptyDefinition(),
|
|
89
|
-
this.getIncrementalDefinition(),
|
|
90
|
-
];
|
|
79
|
+
const definitions = [this.getMaybeValue(), this.getInputMaybeValue()];
|
|
91
80
|
if (this.config.wrapFieldDefinitions) {
|
|
92
81
|
definitions.push(this.getFieldWrapperValue());
|
|
93
82
|
}
|
|
@@ -96,20 +85,6 @@ class TsVisitor extends visitor_plugin_common_1.BaseTypesVisitor {
|
|
|
96
85
|
}
|
|
97
86
|
return definitions;
|
|
98
87
|
}
|
|
99
|
-
getMakeOptionalDefinition() {
|
|
100
|
-
return `${this.getExportPrefix()}${exports.MAKE_OPTIONAL_SIGNATURE}`;
|
|
101
|
-
}
|
|
102
|
-
getMakeMaybeDefinition() {
|
|
103
|
-
if (this.config.onlyEnums)
|
|
104
|
-
return '';
|
|
105
|
-
return `${this.getExportPrefix()}${exports.MAKE_MAYBE_SIGNATURE}`;
|
|
106
|
-
}
|
|
107
|
-
getMakeEmptyDefinition() {
|
|
108
|
-
return `${this.getExportPrefix()}${exports.MAKE_EMPTY_SIGNATURE}`;
|
|
109
|
-
}
|
|
110
|
-
getIncrementalDefinition() {
|
|
111
|
-
return `${this.getExportPrefix()}${exports.MAKE_INCREMENTAL_SIGNATURE}`;
|
|
112
|
-
}
|
|
113
88
|
getMaybeValue() {
|
|
114
89
|
return `${this.getExportPrefix()}type Maybe<T> = ${this.config.maybeValue};`;
|
|
115
90
|
}
|
package/esm/visitor.js
CHANGED
|
@@ -2,10 +2,6 @@ import { BaseTypesVisitor, convertSchemaEnumToDeclarationBlockString, Declaratio
|
|
|
2
2
|
import autoBind from 'auto-bind';
|
|
3
3
|
import { GraphQLObjectType, isEnumType, Kind, } from 'graphql';
|
|
4
4
|
import { TypeScriptOperationVariablesToObject } from './typescript-variables-to-object.js';
|
|
5
|
-
export const MAKE_OPTIONAL_SIGNATURE = `type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };`;
|
|
6
|
-
export const MAKE_MAYBE_SIGNATURE = `type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };`;
|
|
7
|
-
export const MAKE_EMPTY_SIGNATURE = `type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };`;
|
|
8
|
-
export const MAKE_INCREMENTAL_SIGNATURE = `type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };`;
|
|
9
5
|
export class TsVisitor extends BaseTypesVisitor {
|
|
10
6
|
constructor(schema, pluginConfig, additionalConfig = {}) {
|
|
11
7
|
super(schema, pluginConfig, {
|
|
@@ -76,14 +72,7 @@ export class TsVisitor extends BaseTypesVisitor {
|
|
|
76
72
|
getWrapperDefinitions() {
|
|
77
73
|
if (this.config.onlyEnums)
|
|
78
74
|
return [];
|
|
79
|
-
const definitions = [
|
|
80
|
-
this.getMaybeValue(),
|
|
81
|
-
this.getInputMaybeValue(),
|
|
82
|
-
this.getMakeOptionalDefinition(),
|
|
83
|
-
this.getMakeMaybeDefinition(),
|
|
84
|
-
this.getMakeEmptyDefinition(),
|
|
85
|
-
this.getIncrementalDefinition(),
|
|
86
|
-
];
|
|
75
|
+
const definitions = [this.getMaybeValue(), this.getInputMaybeValue()];
|
|
87
76
|
if (this.config.wrapFieldDefinitions) {
|
|
88
77
|
definitions.push(this.getFieldWrapperValue());
|
|
89
78
|
}
|
|
@@ -92,20 +81,6 @@ export class TsVisitor extends BaseTypesVisitor {
|
|
|
92
81
|
}
|
|
93
82
|
return definitions;
|
|
94
83
|
}
|
|
95
|
-
getMakeOptionalDefinition() {
|
|
96
|
-
return `${this.getExportPrefix()}${MAKE_OPTIONAL_SIGNATURE}`;
|
|
97
|
-
}
|
|
98
|
-
getMakeMaybeDefinition() {
|
|
99
|
-
if (this.config.onlyEnums)
|
|
100
|
-
return '';
|
|
101
|
-
return `${this.getExportPrefix()}${MAKE_MAYBE_SIGNATURE}`;
|
|
102
|
-
}
|
|
103
|
-
getMakeEmptyDefinition() {
|
|
104
|
-
return `${this.getExportPrefix()}${MAKE_EMPTY_SIGNATURE}`;
|
|
105
|
-
}
|
|
106
|
-
getIncrementalDefinition() {
|
|
107
|
-
return `${this.getExportPrefix()}${MAKE_INCREMENTAL_SIGNATURE}`;
|
|
108
|
-
}
|
|
109
84
|
getMaybeValue() {
|
|
110
85
|
return `${this.getExportPrefix()}type Maybe<T> = ${this.config.maybeValue};`;
|
|
111
86
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript",
|
|
3
|
-
"version": "6.0.0-alpha-
|
|
3
|
+
"version": "6.0.0-alpha-20260107125844-590bbacbf920ee5f5f207f26f318613d135b0cdb",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating TypeScript types",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@graphql-codegen/plugin-helpers": "^6.1.0",
|
|
10
10
|
"@graphql-codegen/schema-ast": "^5.0.0",
|
|
11
|
-
"@graphql-codegen/visitor-plugin-common": "7.0.0-alpha-
|
|
11
|
+
"@graphql-codegen/visitor-plugin-common": "7.0.0-alpha-20260107125844-590bbacbf920ee5f5f207f26f318613d135b0cdb",
|
|
12
12
|
"auto-bind": "~4.0.0",
|
|
13
13
|
"tslib": "~2.6.0"
|
|
14
14
|
},
|
package/typings/visitor.d.cts
CHANGED
|
@@ -17,18 +17,10 @@ export interface TypeScriptPluginParsedConfig extends ParsedTypesConfig {
|
|
|
17
17
|
noExport: boolean;
|
|
18
18
|
useImplementingTypes: boolean;
|
|
19
19
|
}
|
|
20
|
-
export declare const MAKE_OPTIONAL_SIGNATURE = "type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };";
|
|
21
|
-
export declare const MAKE_MAYBE_SIGNATURE = "type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };";
|
|
22
|
-
export declare const MAKE_EMPTY_SIGNATURE = "type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };";
|
|
23
|
-
export declare const MAKE_INCREMENTAL_SIGNATURE = "type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };";
|
|
24
20
|
export declare class TsVisitor<TRawConfig extends TypeScriptPluginConfig = TypeScriptPluginConfig, TParsedConfig extends TypeScriptPluginParsedConfig = TypeScriptPluginParsedConfig> extends BaseTypesVisitor<TRawConfig, TParsedConfig> {
|
|
25
21
|
constructor(schema: GraphQLSchema, pluginConfig: TRawConfig, additionalConfig?: Partial<TParsedConfig>);
|
|
26
22
|
protected _getTypeForNode(node: NamedTypeNode, isVisitingInputType: boolean): string;
|
|
27
23
|
getWrapperDefinitions(): string[];
|
|
28
|
-
getMakeOptionalDefinition(): string;
|
|
29
|
-
getMakeMaybeDefinition(): string;
|
|
30
|
-
getMakeEmptyDefinition(): string;
|
|
31
|
-
getIncrementalDefinition(): string;
|
|
32
24
|
getMaybeValue(): string;
|
|
33
25
|
getInputMaybeValue(): string;
|
|
34
26
|
protected clearOptional(str: string): string;
|
package/typings/visitor.d.ts
CHANGED
|
@@ -17,18 +17,10 @@ export interface TypeScriptPluginParsedConfig extends ParsedTypesConfig {
|
|
|
17
17
|
noExport: boolean;
|
|
18
18
|
useImplementingTypes: boolean;
|
|
19
19
|
}
|
|
20
|
-
export declare const MAKE_OPTIONAL_SIGNATURE = "type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };";
|
|
21
|
-
export declare const MAKE_MAYBE_SIGNATURE = "type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };";
|
|
22
|
-
export declare const MAKE_EMPTY_SIGNATURE = "type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };";
|
|
23
|
-
export declare const MAKE_INCREMENTAL_SIGNATURE = "type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };";
|
|
24
20
|
export declare class TsVisitor<TRawConfig extends TypeScriptPluginConfig = TypeScriptPluginConfig, TParsedConfig extends TypeScriptPluginParsedConfig = TypeScriptPluginParsedConfig> extends BaseTypesVisitor<TRawConfig, TParsedConfig> {
|
|
25
21
|
constructor(schema: GraphQLSchema, pluginConfig: TRawConfig, additionalConfig?: Partial<TParsedConfig>);
|
|
26
22
|
protected _getTypeForNode(node: NamedTypeNode, isVisitingInputType: boolean): string;
|
|
27
23
|
getWrapperDefinitions(): string[];
|
|
28
|
-
getMakeOptionalDefinition(): string;
|
|
29
|
-
getMakeMaybeDefinition(): string;
|
|
30
|
-
getMakeEmptyDefinition(): string;
|
|
31
|
-
getIncrementalDefinition(): string;
|
|
32
24
|
getMaybeValue(): string;
|
|
33
25
|
getInputMaybeValue(): string;
|
|
34
26
|
protected clearOptional(str: string): string;
|