@graphql-codegen/cli 5.0.6-alpha-20250414132312-2cacfbb956012f0df94008f4636b6c03ccca15b4 → 5.0.6-alpha-20250414134255-909e355dc0f649c1f9d52ec7dbf5ab1b99ccc909

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/codegen.js CHANGED
@@ -8,6 +8,7 @@ const os_1 = require("os");
8
8
  const path_1 = tslib_1.__importDefault(require("path"));
9
9
  const core_1 = require("@graphql-codegen/core");
10
10
  const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
11
+ const load_1 = require("@graphql-tools/load");
11
12
  const graphql_1 = require("graphql");
12
13
  const listr2_1 = require("listr2");
13
14
  const config_js_1 = require("./config.js");
@@ -221,7 +222,7 @@ async function executeCodegen(input) {
221
222
  };
222
223
  }
223
224
  catch (error) {
224
- if (config.ignoreNoDocuments) {
225
+ if (error instanceof load_1.NoTypeDefinitionsFound && config.ignoreNoDocuments) {
225
226
  return {
226
227
  documents: [],
227
228
  };
@@ -124,9 +124,7 @@ function isConfiguredOutput(output) {
124
124
  }
125
125
  async function hashFile(filePath) {
126
126
  try {
127
- const fileContent = await (0, file_system_js_1.readFile)(filePath);
128
- fileContent.replace(/\r\n/g, '\n');
129
- return hash(fileContent);
127
+ return hash(await (0, file_system_js_1.readFile)(filePath));
130
128
  }
131
129
  catch (err) {
132
130
  if (err && err.code === 'ENOENT') {
package/cjs/load.js CHANGED
@@ -88,8 +88,11 @@ async function loadDocuments(documentPointers, config) {
88
88
  return loadedFromToolkit;
89
89
  }
90
90
  catch (error) {
91
- if (config.ignoreNoDocuments)
92
- return [];
91
+ // NoTypeDefinitionsFound from `@graphql-tools/load` already has a message with pointer, so we can just rethrow the error
92
+ if (error instanceof load_1.NoTypeDefinitionsFound) {
93
+ throw error;
94
+ }
95
+ // For other errors, we need to add an error message with documentPointers, so it's better for DevX
93
96
  throw new Error([`Failed to load documents from ${Object.keys(documentPointers).join(',')}:`, printError(error)].join('\n'));
94
97
  }
95
98
  }
package/esm/codegen.js CHANGED
@@ -4,6 +4,7 @@ import { cpus } from 'os';
4
4
  import path from 'path';
5
5
  import { codegen } from '@graphql-codegen/core';
6
6
  import { getCachedDocumentNodeFromSchema, normalizeConfig, normalizeInstanceOrArray, normalizeOutputParam, } from '@graphql-codegen/plugin-helpers';
7
+ import { NoTypeDefinitionsFound } from '@graphql-tools/load';
7
8
  import { GraphQLError } from 'graphql';
8
9
  import { Listr } from 'listr2';
9
10
  import { ensureContext, shouldEmitLegacyCommonJSImports } from './config.js';
@@ -217,7 +218,7 @@ export async function executeCodegen(input) {
217
218
  };
218
219
  }
219
220
  catch (error) {
220
- if (config.ignoreNoDocuments) {
221
+ if (error instanceof NoTypeDefinitionsFound && config.ignoreNoDocuments) {
221
222
  return {
222
223
  documents: [],
223
224
  };
@@ -121,9 +121,7 @@ function isConfiguredOutput(output) {
121
121
  }
122
122
  async function hashFile(filePath) {
123
123
  try {
124
- const fileContent = await readFile(filePath);
125
- fileContent.replace(/\r\n/g, '\n');
126
- return hash(fileContent);
124
+ return hash(await readFile(filePath));
127
125
  }
128
126
  catch (err) {
129
127
  if (err && err.code === 'ENOENT') {
package/esm/load.js CHANGED
@@ -5,7 +5,7 @@ import { GitLoader } from '@graphql-tools/git-loader';
5
5
  import { GithubLoader } from '@graphql-tools/github-loader';
6
6
  import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader';
7
7
  import { JsonFileLoader } from '@graphql-tools/json-file-loader';
8
- import { loadDocuments as loadDocumentsToolkit, loadSchema as loadSchemaToolkit, } from '@graphql-tools/load';
8
+ import { loadDocuments as loadDocumentsToolkit, loadSchema as loadSchemaToolkit, NoTypeDefinitionsFound, } from '@graphql-tools/load';
9
9
  import { PrismaLoader } from '@graphql-tools/prisma-loader';
10
10
  import { UrlLoader } from '@graphql-tools/url-loader';
11
11
  import { GraphQLError } from 'graphql';
@@ -83,8 +83,11 @@ export async function loadDocuments(documentPointers, config) {
83
83
  return loadedFromToolkit;
84
84
  }
85
85
  catch (error) {
86
- if (config.ignoreNoDocuments)
87
- return [];
86
+ // NoTypeDefinitionsFound from `@graphql-tools/load` already has a message with pointer, so we can just rethrow the error
87
+ if (error instanceof NoTypeDefinitionsFound) {
88
+ throw error;
89
+ }
90
+ // For other errors, we need to add an error message with documentPointers, so it's better for DevX
88
91
  throw new Error([`Failed to load documents from ${Object.keys(documentPointers).join(',')}:`, printError(error)].join('\n'));
89
92
  }
90
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/cli",
3
- "version": "5.0.6-alpha-20250414132312-2cacfbb956012f0df94008f4636b6c03ccca15b4",
3
+ "version": "5.0.6-alpha-20250414134255-909e355dc0f649c1f9d52ec7dbf5ab1b99ccc909",
4
4
  "peerDependenciesMeta": {
5
5
  "@parcel/watcher": {
6
6
  "optional": true
@@ -14,7 +14,7 @@
14
14
  "@babel/generator": "^7.18.13",
15
15
  "@babel/template": "^7.18.10",
16
16
  "@babel/types": "^7.18.13",
17
- "@graphql-codegen/client-preset": "4.8.1-alpha-20250414132312-2cacfbb956012f0df94008f4636b6c03ccca15b4",
17
+ "@graphql-codegen/client-preset": "4.8.1-alpha-20250414134255-909e355dc0f649c1f9d52ec7dbf5ab1b99ccc909",
18
18
  "@graphql-codegen/core": "^4.0.2",
19
19
  "@graphql-codegen/plugin-helpers": "^5.0.3",
20
20
  "@graphql-tools/apollo-engine-loader": "^8.0.0",
@@ -23,7 +23,7 @@
23
23
  "@graphql-tools/github-loader": "^8.0.0",
24
24
  "@graphql-tools/graphql-file-loader": "^8.0.0",
25
25
  "@graphql-tools/json-file-loader": "^8.0.0",
26
- "@graphql-tools/load": "^8.0.0",
26
+ "@graphql-tools/load": "^8.1.0",
27
27
  "@graphql-tools/prisma-loader": "^8.0.0",
28
28
  "@graphql-tools/url-loader": "^8.0.0",
29
29
  "@graphql-tools/utils": "^10.0.0",
@@ -32,7 +32,7 @@
32
32
  "cosmiconfig": "^8.1.3",
33
33
  "debounce": "^1.2.0",
34
34
  "detect-indent": "^6.0.0",
35
- "graphql-config": "^5.1.1",
35
+ "graphql-config": "^5.1.4",
36
36
  "inquirer": "^8.0.0",
37
37
  "is-glob": "^4.0.1",
38
38
  "jiti": "^1.17.1",