@graphql-codegen/typescript-resolvers 5.0.0-alpha-20250311213828-b0b7e86bc292eaf1e1b50e494e0e1f7af2fef9d2 → 5.0.0-alpha-20250329081240-1a64f6d2f211bdd3623a04b001a1dab8e0c92d3c

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 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,9 +80,12 @@ export type Resolver${capitalizedDirectiveName}WithResolve<TResult, TParent, TCo
57
80
  directiveResolverMappings[directiveName] = resolverTypeName;
58
81
  }
59
82
  }
60
- const { transformedSchema, federationMeta } = config.federation
83
+ let { transformedSchema, federationMeta } = config.federation
61
84
  ? (0, plugin_helpers_1.addFederationReferencesToSchema)(schema)
62
85
  : { transformedSchema: schema, federationMeta: {} };
86
+ transformedSchema = config.customDirectives?.semanticNonNull
87
+ ? await semanticToStrict(transformedSchema)
88
+ : transformedSchema;
63
89
  const visitor = new visitor_js_1.TypeScriptResolversVisitor({ ...config, directiveResolverMappings }, transformedSchema, federationMeta);
64
90
  const namespacedImportPrefix = visitor.config.namespacedImportName ? `${visitor.config.namespacedImportName}.` : '';
65
91
  const astNode = (0, plugin_helpers_1.getCachedDocumentNodeFromSchema)(transformedSchema);
@@ -255,3 +281,12 @@ export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs
255
281
  };
256
282
  };
257
283
  exports.plugin = plugin;
284
+ const semanticToStrict = async (schema) => {
285
+ try {
286
+ const sock = await Promise.resolve().then(() => __importStar(require('graphql-sock')));
287
+ return sock.semanticToStrict(schema);
288
+ }
289
+ catch {
290
+ throw new Error("To use the `customDirective.semanticNonNull` option, you must install the 'graphql-sock' package.");
291
+ }
292
+ };
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,9 +53,12 @@ export type Resolver${capitalizedDirectiveName}WithResolve<TResult, TParent, TCo
53
53
  directiveResolverMappings[directiveName] = resolverTypeName;
54
54
  }
55
55
  }
56
- const { transformedSchema, federationMeta } = config.federation
56
+ let { transformedSchema, federationMeta } = config.federation
57
57
  ? addFederationReferencesToSchema(schema)
58
58
  : { transformedSchema: schema, federationMeta: {} };
59
+ transformedSchema = config.customDirectives?.semanticNonNull
60
+ ? await semanticToStrict(transformedSchema)
61
+ : transformedSchema;
59
62
  const visitor = new TypeScriptResolversVisitor({ ...config, directiveResolverMappings }, transformedSchema, federationMeta);
60
63
  const namespacedImportPrefix = visitor.config.namespacedImportName ? `${visitor.config.namespacedImportName}.` : '';
61
64
  const astNode = getCachedDocumentNodeFromSchema(transformedSchema);
@@ -251,3 +254,12 @@ export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs
251
254
  };
252
255
  };
253
256
  export { TypeScriptResolversVisitor };
257
+ const semanticToStrict = async (schema) => {
258
+ try {
259
+ const sock = await import('graphql-sock');
260
+ return sock.semanticToStrict(schema);
261
+ }
262
+ catch {
263
+ throw new Error("To use the `customDirective.semanticNonNull` option, you must install the 'graphql-sock' package.");
264
+ }
265
+ };
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript-resolvers",
3
- "version": "5.0.0-alpha-20250311213828-b0b7e86bc292eaf1e1b50e494e0e1f7af2fef9d2",
3
+ "version": "5.0.0-alpha-20250329081240-1a64f6d2f211bdd3623a04b001a1dab8e0c92d3c",
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": "6.0.0-alpha-20250311213828-b0b7e86bc292eaf1e1b50e494e0e1f7af2fef9d2",
10
- "@graphql-codegen/typescript": "4.1.6-alpha-20250311213828-b0b7e86bc292eaf1e1b50e494e0e1f7af2fef9d2",
11
- "@graphql-codegen/visitor-plugin-common": "6.0.0-alpha-20250311213828-b0b7e86bc292eaf1e1b50e494e0e1f7af2fef9d2",
10
+ "@graphql-codegen/plugin-helpers": "6.0.0-alpha-20250329081240-1a64f6d2f211bdd3623a04b001a1dab8e0c92d3c",
11
+ "@graphql-codegen/typescript": "4.1.7-alpha-20250329081240-1a64f6d2f211bdd3623a04b001a1dab8e0c92d3c",
12
+ "@graphql-codegen/visitor-plugin-common": "6.0.0-alpha-20250329081240-1a64f6d2f211bdd3623a04b001a1dab8e0c92d3c",
12
13
  "@graphql-tools/utils": "^10.0.0",
13
14
  "auto-bind": "~4.0.0",
14
15
  "tslib": "~2.6.0"