@graphql-codegen/client-preset 4.7.1-alpha-20250324064325-1385e9acaec80b477dab2459c7be7e985d8e6feb → 4.7.1-alpha-20250324095158-f496af22ad6a03474db09dba9c9c0eac27eb2a28

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
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "babelOptimizerPlugin", { enumerable: true, get:
16
16
  const isOutputFolderLike = (baseOutputDir) => baseOutputDir.endsWith('/');
17
17
  exports.preset = {
18
18
  prepareDocuments: (outputFilePath, outputSpecificDocuments) => [...outputSpecificDocuments, `!${outputFilePath}`],
19
- buildGeneratesSection: options => {
19
+ buildGeneratesSection: async (options) => {
20
20
  if (!isOutputFolderLike(options.baseOutputDir)) {
21
21
  throw new Error('[client-preset] target output should be a directory, ex: "src/gql/". Make sure you add "/" at the end of the directory path');
22
22
  }
@@ -24,6 +24,10 @@ exports.preset = {
24
24
  throw new Error('[client-preset] providing typescript-based `plugins` with `preset: "client" leads to duplicated generated types');
25
25
  }
26
26
  const isPersistedOperations = !!options.presetConfig?.persistedDocuments;
27
+ if (options.config.semanticNonNull?.errorHandlingClient) {
28
+ options.schemaAst = await semanticToStrict(options.schemaAst);
29
+ options.schema = options.schemaAst; // FIXME: `schemaAst` _seems_ to be able to used as `schema`, but not sure if it has any side effects?
30
+ }
27
31
  const reexports = [];
28
32
  // the `client` preset is restricting the config options inherited from `typescript`, `typescript-operations` and others.
29
33
  const forwardedConfig = {
@@ -246,5 +250,14 @@ function createDeferred() {
246
250
  });
247
251
  return d;
248
252
  }
253
+ const semanticToStrict = async (schema) => {
254
+ try {
255
+ const sock = await Promise.resolve().then(() => tslib_1.__importStar(require('graphql-sock')));
256
+ return sock.semanticToStrict(schema);
257
+ }
258
+ catch {
259
+ throw new Error("To use the `customDirective.semanticNonNull` option, you must install the 'graphql-sock' package.");
260
+ }
261
+ };
249
262
  var add_typename_selection_document_transform_js_1 = require("./add-typename-selection-document-transform.js");
250
263
  Object.defineProperty(exports, "addTypenameSelectionDocumentTransform", { enumerable: true, get: function () { return add_typename_selection_document_transform_js_1.addTypenameSelectionDocumentTransform; } });
package/esm/index.js CHANGED
@@ -11,7 +11,7 @@ export { default as babelOptimizerPlugin } from './babel.js';
11
11
  const isOutputFolderLike = (baseOutputDir) => baseOutputDir.endsWith('/');
12
12
  export const preset = {
13
13
  prepareDocuments: (outputFilePath, outputSpecificDocuments) => [...outputSpecificDocuments, `!${outputFilePath}`],
14
- buildGeneratesSection: options => {
14
+ buildGeneratesSection: async (options) => {
15
15
  if (!isOutputFolderLike(options.baseOutputDir)) {
16
16
  throw new Error('[client-preset] target output should be a directory, ex: "src/gql/". Make sure you add "/" at the end of the directory path');
17
17
  }
@@ -19,6 +19,10 @@ export const preset = {
19
19
  throw new Error('[client-preset] providing typescript-based `plugins` with `preset: "client" leads to duplicated generated types');
20
20
  }
21
21
  const isPersistedOperations = !!options.presetConfig?.persistedDocuments;
22
+ if (options.config.semanticNonNull?.errorHandlingClient) {
23
+ options.schemaAst = await semanticToStrict(options.schemaAst);
24
+ options.schema = options.schemaAst; // FIXME: `schemaAst` _seems_ to be able to used as `schema`, but not sure if it has any side effects?
25
+ }
22
26
  const reexports = [];
23
27
  // the `client` preset is restricting the config options inherited from `typescript`, `typescript-operations` and others.
24
28
  const forwardedConfig = {
@@ -241,4 +245,13 @@ function createDeferred() {
241
245
  });
242
246
  return d;
243
247
  }
248
+ const semanticToStrict = async (schema) => {
249
+ try {
250
+ const sock = await import('graphql-sock');
251
+ return sock.semanticToStrict(schema);
252
+ }
253
+ catch {
254
+ throw new Error("To use the `customDirective.semanticNonNull` option, you must install the 'graphql-sock' package.");
255
+ }
256
+ };
244
257
  export { addTypenameSelectionDocumentTransform } from './add-typename-selection-document-transform.js';
package/package.json CHANGED
@@ -1,20 +1,21 @@
1
1
  {
2
2
  "name": "@graphql-codegen/client-preset",
3
- "version": "4.7.1-alpha-20250324064325-1385e9acaec80b477dab2459c7be7e985d8e6feb",
3
+ "version": "4.7.1-alpha-20250324095158-f496af22ad6a03474db09dba9c9c0eac27eb2a28",
4
4
  "description": "GraphQL Code Generator preset for client.",
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
10
  "@babel/helper-plugin-utils": "^7.20.2",
10
11
  "@babel/template": "^7.20.7",
11
12
  "@graphql-codegen/add": "^5.0.3",
12
- "@graphql-codegen/typed-document-node": "5.1.1-alpha-20250324064325-1385e9acaec80b477dab2459c7be7e985d8e6feb",
13
- "@graphql-codegen/typescript": "4.1.6-alpha-20250324064325-1385e9acaec80b477dab2459c7be7e985d8e6feb",
14
- "@graphql-codegen/typescript-operations": "4.5.2-alpha-20250324064325-1385e9acaec80b477dab2459c7be7e985d8e6feb",
15
- "@graphql-codegen/gql-tag-operations": "4.0.17-alpha-20250324064325-1385e9acaec80b477dab2459c7be7e985d8e6feb",
13
+ "@graphql-codegen/typed-document-node": "5.1.1-alpha-20250324095158-f496af22ad6a03474db09dba9c9c0eac27eb2a28",
14
+ "@graphql-codegen/typescript": "4.1.6-alpha-20250324095158-f496af22ad6a03474db09dba9c9c0eac27eb2a28",
15
+ "@graphql-codegen/typescript-operations": "4.6.0-alpha-20250324095158-f496af22ad6a03474db09dba9c9c0eac27eb2a28",
16
+ "@graphql-codegen/gql-tag-operations": "4.0.17-alpha-20250324095158-f496af22ad6a03474db09dba9c9c0eac27eb2a28",
16
17
  "@graphql-codegen/plugin-helpers": "^5.1.0",
17
- "@graphql-codegen/visitor-plugin-common": "5.8.0-alpha-20250324064325-1385e9acaec80b477dab2459c7be7e985d8e6feb",
18
+ "@graphql-codegen/visitor-plugin-common": "5.8.0-alpha-20250324095158-f496af22ad6a03474db09dba9c9c0eac27eb2a28",
18
19
  "@graphql-typed-document-node/core": "3.2.0",
19
20
  "@graphql-tools/documents": "^1.0.0",
20
21
  "@graphql-tools/utils": "^10.0.0",
@@ -1,5 +1,5 @@
1
1
  import type { Types } from '@graphql-codegen/plugin-helpers';
2
- import { DocumentNode } from 'graphql';
2
+ import type { DocumentNode } from 'graphql';
3
3
  export { default as babelOptimizerPlugin } from './babel.cjs';
4
4
  export type FragmentMaskingConfig = {
5
5
  /** @description Name of the function that should be used for unmasking a masked fragment property.
@@ -1,5 +1,5 @@
1
1
  import type { Types } from '@graphql-codegen/plugin-helpers';
2
- import { DocumentNode } from 'graphql';
2
+ import type { DocumentNode } from 'graphql';
3
3
  export { default as babelOptimizerPlugin } from './babel.js';
4
4
  export type FragmentMaskingConfig = {
5
5
  /** @description Name of the function that should be used for unmasking a masked fragment property.