@graphql-codegen/typescript-resolvers 4.4.5-alpha-20250314001208-26b650f2e9df4ac12ed3c6875084807691bbe9f0 → 4.5.0-alpha-20250320115712-0c95c1869f1781093936579f0f8ebc1091082c5c
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 +37 -2
- package/cjs/visitor.js +0 -6
- package/esm/index.js +14 -2
- package/esm/visitor.js +0 -6
- package/package.json +7 -6
- package/typings/visitor.d.cts +0 -1
- package/typings/visitor.d.ts +0 -1
package/cjs/index.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.TypeScriptResolversVisitor = exports.plugin = void 0;
|
|
4
27
|
const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
|
|
@@ -6,7 +29,7 @@ const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common"
|
|
|
6
29
|
const visitor_js_1 = require("./visitor.js");
|
|
7
30
|
Object.defineProperty(exports, "TypeScriptResolversVisitor", { enumerable: true, get: function () { return visitor_js_1.TypeScriptResolversVisitor; } });
|
|
8
31
|
const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
9
|
-
const plugin = (schema, documents, config) => {
|
|
32
|
+
const plugin = async (schema, documents, config) => {
|
|
10
33
|
const imports = [];
|
|
11
34
|
if (!config.customResolveInfo) {
|
|
12
35
|
imports.push('GraphQLResolveInfo');
|
|
@@ -57,7 +80,10 @@ export type Resolver${capitalizedDirectiveName}WithResolve<TResult, TParent, TCo
|
|
|
57
80
|
directiveResolverMappings[directiveName] = resolverTypeName;
|
|
58
81
|
}
|
|
59
82
|
}
|
|
60
|
-
|
|
83
|
+
let transformedSchema = config.federation ? (0, plugin_helpers_1.addFederationReferencesToSchema)(schema) : schema;
|
|
84
|
+
transformedSchema = config.customDirectives.semanticNonNull
|
|
85
|
+
? await semanticToStrict(transformedSchema)
|
|
86
|
+
: transformedSchema;
|
|
61
87
|
const visitor = new visitor_js_1.TypeScriptResolversVisitor({ ...config, directiveResolverMappings }, transformedSchema);
|
|
62
88
|
const namespacedImportPrefix = visitor.config.namespacedImportName ? `${visitor.config.namespacedImportName}.` : '';
|
|
63
89
|
const astNode = (0, plugin_helpers_1.getCachedDocumentNodeFromSchema)(transformedSchema);
|
|
@@ -257,3 +283,12 @@ export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs
|
|
|
257
283
|
};
|
|
258
284
|
};
|
|
259
285
|
exports.plugin = plugin;
|
|
286
|
+
const semanticToStrict = async (schema) => {
|
|
287
|
+
try {
|
|
288
|
+
const sock = await Promise.resolve().then(() => __importStar(require('graphql-sock')));
|
|
289
|
+
return sock.semanticToStrict(schema);
|
|
290
|
+
}
|
|
291
|
+
catch {
|
|
292
|
+
throw new Error("To use the `customDirective.semanticNonNull` option, you must install the 'graphql-sock' package.");
|
|
293
|
+
}
|
|
294
|
+
};
|
package/cjs/visitor.js
CHANGED
|
@@ -35,12 +35,6 @@ class TypeScriptResolversVisitor extends visitor_plugin_common_1.BaseResolversVi
|
|
|
35
35
|
const avoidOptionals = this.config.avoidOptionals.resolvers;
|
|
36
36
|
return `${schemaTypeName}${avoidOptionals ? '' : '?'}: ${resolverType}${this.getPunctuation(declarationKind)}`;
|
|
37
37
|
}
|
|
38
|
-
clearOptional(str) {
|
|
39
|
-
if (str.startsWith('Maybe')) {
|
|
40
|
-
return str.replace(/Maybe<(.*?)>$/, '$1');
|
|
41
|
-
}
|
|
42
|
-
return str;
|
|
43
|
-
}
|
|
44
38
|
ListType(node) {
|
|
45
39
|
return `Maybe<${super.ListType(node)}>`;
|
|
46
40
|
}
|
package/esm/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { addFederationReferencesToSchema, getCachedDocumentNodeFromSchema, oldVi
|
|
|
2
2
|
import { parseMapper } from '@graphql-codegen/visitor-plugin-common';
|
|
3
3
|
import { TypeScriptResolversVisitor } from './visitor.js';
|
|
4
4
|
const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
5
|
-
export const plugin = (schema, documents, config) => {
|
|
5
|
+
export const plugin = async (schema, documents, config) => {
|
|
6
6
|
const imports = [];
|
|
7
7
|
if (!config.customResolveInfo) {
|
|
8
8
|
imports.push('GraphQLResolveInfo');
|
|
@@ -53,7 +53,10 @@ export type Resolver${capitalizedDirectiveName}WithResolve<TResult, TParent, TCo
|
|
|
53
53
|
directiveResolverMappings[directiveName] = resolverTypeName;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
let transformedSchema = config.federation ? addFederationReferencesToSchema(schema) : schema;
|
|
57
|
+
transformedSchema = config.customDirectives.semanticNonNull
|
|
58
|
+
? await semanticToStrict(transformedSchema)
|
|
59
|
+
: transformedSchema;
|
|
57
60
|
const visitor = new TypeScriptResolversVisitor({ ...config, directiveResolverMappings }, transformedSchema);
|
|
58
61
|
const namespacedImportPrefix = visitor.config.namespacedImportName ? `${visitor.config.namespacedImportName}.` : '';
|
|
59
62
|
const astNode = getCachedDocumentNodeFromSchema(transformedSchema);
|
|
@@ -253,3 +256,12 @@ export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs
|
|
|
253
256
|
};
|
|
254
257
|
};
|
|
255
258
|
export { TypeScriptResolversVisitor };
|
|
259
|
+
const semanticToStrict = async (schema) => {
|
|
260
|
+
try {
|
|
261
|
+
const sock = await import('graphql-sock');
|
|
262
|
+
return sock.semanticToStrict(schema);
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
throw new Error("To use the `customDirective.semanticNonNull` option, you must install the 'graphql-sock' package.");
|
|
266
|
+
}
|
|
267
|
+
};
|
package/esm/visitor.js
CHANGED
|
@@ -31,12 +31,6 @@ export class TypeScriptResolversVisitor extends BaseResolversVisitor {
|
|
|
31
31
|
const avoidOptionals = this.config.avoidOptionals.resolvers;
|
|
32
32
|
return `${schemaTypeName}${avoidOptionals ? '' : '?'}: ${resolverType}${this.getPunctuation(declarationKind)}`;
|
|
33
33
|
}
|
|
34
|
-
clearOptional(str) {
|
|
35
|
-
if (str.startsWith('Maybe')) {
|
|
36
|
-
return str.replace(/Maybe<(.*?)>$/, '$1');
|
|
37
|
-
}
|
|
38
|
-
return str;
|
|
39
|
-
}
|
|
40
34
|
ListType(node) {
|
|
41
35
|
return `Maybe<${super.ListType(node)}>`;
|
|
42
36
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-resolvers",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0-alpha-20250320115712-0c95c1869f1781093936579f0f8ebc1091082c5c",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating TypeScript types for resolvers signature",
|
|
5
5
|
"peerDependencies": {
|
|
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"
|
|
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
|
+
"graphql-sock": "^1.0.0"
|
|
7
8
|
},
|
|
8
9
|
"dependencies": {
|
|
9
|
-
"@graphql-codegen/plugin-helpers": "5.1.
|
|
10
|
-
"@graphql-codegen/typescript": "4.1.6-alpha-
|
|
11
|
-
"@graphql-codegen/visitor-plugin-common": "5.
|
|
10
|
+
"@graphql-codegen/plugin-helpers": "^5.1.0",
|
|
11
|
+
"@graphql-codegen/typescript": "4.1.6-alpha-20250320115712-0c95c1869f1781093936579f0f8ebc1091082c5c",
|
|
12
|
+
"@graphql-codegen/visitor-plugin-common": "5.8.0-alpha-20250320115712-0c95c1869f1781093936579f0f8ebc1091082c5c",
|
|
12
13
|
"@graphql-tools/utils": "^10.0.0",
|
|
13
14
|
"auto-bind": "~4.0.0",
|
|
14
|
-
"tslib": "~2.
|
|
15
|
+
"tslib": "~2.6.0"
|
|
15
16
|
},
|
|
16
17
|
"repository": {
|
|
17
18
|
"type": "git",
|
package/typings/visitor.d.cts
CHANGED
|
@@ -12,7 +12,6 @@ export declare class TypeScriptResolversVisitor extends BaseResolversVisitor<Typ
|
|
|
12
12
|
constructor(pluginConfig: TypeScriptResolversPluginConfig, schema: GraphQLSchema);
|
|
13
13
|
protected transformParentGenericType(parentType: string): string;
|
|
14
14
|
protected formatRootResolver(schemaTypeName: string, resolverType: string, declarationKind: DeclarationKind): string;
|
|
15
|
-
private clearOptional;
|
|
16
15
|
ListType(node: ListTypeNode): string;
|
|
17
16
|
protected wrapWithListType(str: string): string;
|
|
18
17
|
protected getParentTypeForSignature(node: FieldDefinitionNode): "ParentType" | "UnwrappedObject<ParentType>";
|
package/typings/visitor.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export declare class TypeScriptResolversVisitor extends BaseResolversVisitor<Typ
|
|
|
12
12
|
constructor(pluginConfig: TypeScriptResolversPluginConfig, schema: GraphQLSchema);
|
|
13
13
|
protected transformParentGenericType(parentType: string): string;
|
|
14
14
|
protected formatRootResolver(schemaTypeName: string, resolverType: string, declarationKind: DeclarationKind): string;
|
|
15
|
-
private clearOptional;
|
|
16
15
|
ListType(node: ListTypeNode): string;
|
|
17
16
|
protected wrapWithListType(str: string): string;
|
|
18
17
|
protected getParentTypeForSignature(node: FieldDefinitionNode): "ParentType" | "UnwrappedObject<ParentType>";
|