@graphql-codegen/typescript-operations 3.0.3-rc-20230320132329-5e109e8f8 → 3.1.0-alpha-20230320164155-162269dfc
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.
|
@@ -11,18 +11,18 @@ class TypeScriptSelectionSetProcessor extends visitor_plugin_common_1.BaseSelect
|
|
|
11
11
|
this.config.convertName(schemaType.name, {
|
|
12
12
|
useTypesPrefix: true,
|
|
13
13
|
});
|
|
14
|
-
let
|
|
15
|
-
const
|
|
14
|
+
let hasOptional = false;
|
|
15
|
+
const optionalList = [];
|
|
16
16
|
let resString = `Pick<${parentName}, ${fields
|
|
17
17
|
.map(field => {
|
|
18
18
|
if (field.isConditional) {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
hasOptional = true;
|
|
20
|
+
optionalList.push(field.fieldName);
|
|
21
21
|
}
|
|
22
22
|
return `'${field.fieldName}'`;
|
|
23
23
|
})
|
|
24
24
|
.join(' | ')}>`;
|
|
25
|
-
if (
|
|
25
|
+
if (hasOptional) {
|
|
26
26
|
const avoidOptional =
|
|
27
27
|
// TODO: check type and exec only if relevant
|
|
28
28
|
this.config.avoidOptionals === true ||
|
|
@@ -31,7 +31,7 @@ class TypeScriptSelectionSetProcessor extends visitor_plugin_common_1.BaseSelect
|
|
|
31
31
|
this.config.avoidOptionals.inputValue ||
|
|
32
32
|
this.config.avoidOptionals.object));
|
|
33
33
|
const transform = avoidOptional ? 'MakeMaybe' : 'MakeOptional';
|
|
34
|
-
resString = `${this.config.namespacedImportName ? `${this.config.namespacedImportName}.` : ''}${transform}<${resString}, ${
|
|
34
|
+
resString = `${this.config.namespacedImportName ? `${this.config.namespacedImportName}.` : ''}${transform}<${resString}, ${optionalList.map(field => `'${field}'`).join(' | ')}>`;
|
|
35
35
|
}
|
|
36
36
|
return [resString];
|
|
37
37
|
}
|
|
@@ -8,18 +8,18 @@ export class TypeScriptSelectionSetProcessor extends BaseSelectionSetProcessor {
|
|
|
8
8
|
this.config.convertName(schemaType.name, {
|
|
9
9
|
useTypesPrefix: true,
|
|
10
10
|
});
|
|
11
|
-
let
|
|
12
|
-
const
|
|
11
|
+
let hasOptional = false;
|
|
12
|
+
const optionalList = [];
|
|
13
13
|
let resString = `Pick<${parentName}, ${fields
|
|
14
14
|
.map(field => {
|
|
15
15
|
if (field.isConditional) {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
hasOptional = true;
|
|
17
|
+
optionalList.push(field.fieldName);
|
|
18
18
|
}
|
|
19
19
|
return `'${field.fieldName}'`;
|
|
20
20
|
})
|
|
21
21
|
.join(' | ')}>`;
|
|
22
|
-
if (
|
|
22
|
+
if (hasOptional) {
|
|
23
23
|
const avoidOptional =
|
|
24
24
|
// TODO: check type and exec only if relevant
|
|
25
25
|
this.config.avoidOptionals === true ||
|
|
@@ -28,7 +28,7 @@ export class TypeScriptSelectionSetProcessor extends BaseSelectionSetProcessor {
|
|
|
28
28
|
this.config.avoidOptionals.inputValue ||
|
|
29
29
|
this.config.avoidOptionals.object));
|
|
30
30
|
const transform = avoidOptional ? 'MakeMaybe' : 'MakeOptional';
|
|
31
|
-
resString = `${this.config.namespacedImportName ? `${this.config.namespacedImportName}.` : ''}${transform}<${resString}, ${
|
|
31
|
+
resString = `${this.config.namespacedImportName ? `${this.config.namespacedImportName}.` : ''}${transform}<${resString}, ${optionalList.map(field => `'${field}'`).join(' | ')}>`;
|
|
32
32
|
}
|
|
33
33
|
return [resString];
|
|
34
34
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-operations",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0-alpha-20230320164155-162269dfc",
|
|
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"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@graphql-codegen/plugin-helpers": "4.2.0-
|
|
10
|
-
"@graphql-codegen/typescript": "3.0.3-
|
|
11
|
-
"@graphql-codegen/visitor-plugin-common": "3.1.0-
|
|
9
|
+
"@graphql-codegen/plugin-helpers": "4.2.0-alpha-20230320164155-162269dfc",
|
|
10
|
+
"@graphql-codegen/typescript": "3.0.3-alpha-20230320164155-162269dfc",
|
|
11
|
+
"@graphql-codegen/visitor-plugin-common": "3.1.0-alpha-20230320164155-162269dfc",
|
|
12
12
|
"auto-bind": "~4.0.0",
|
|
13
13
|
"tslib": "~2.5.0"
|
|
14
14
|
},
|