@graphql-codegen/cli 7.4.0 → 7.4.1-alpha-20260906052927-fb05cdd753213e6c67cf8cb80fc55a6d47eaecfb
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 +6 -11
- package/cjs/config.js +3 -10
- package/cjs/utils/watcher.js +8 -3
- package/cjs/version.js +1 -1
- package/esm/codegen.js +6 -11
- package/esm/config.js +3 -10
- package/esm/utils/watcher.js +9 -4
- package/esm/version.js +1 -1
- package/package.json +3 -3
package/cjs/codegen.js
CHANGED
|
@@ -6,6 +6,7 @@ const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
|
6
6
|
const module_1 = require("module");
|
|
7
7
|
const os_1 = require("os");
|
|
8
8
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
|
+
const url_1 = require("url");
|
|
9
10
|
const graphql_1 = require("graphql");
|
|
10
11
|
const listr2_1 = require("listr2");
|
|
11
12
|
const core_1 = require("@graphql-codegen/core");
|
|
@@ -14,7 +15,6 @@ const load_1 = require("@graphql-tools/load");
|
|
|
14
15
|
const merge_1 = require("@graphql-tools/merge");
|
|
15
16
|
const config_js_1 = require("./config.js");
|
|
16
17
|
const documentTransforms_js_1 = require("./documentTransforms.js");
|
|
17
|
-
const isESMModule_js_1 = require("./isESMModule.js");
|
|
18
18
|
const plugins_js_1 = require("./plugins.js");
|
|
19
19
|
const presets_js_1 = require("./presets.js");
|
|
20
20
|
const debugging_js_1 = require("./utils/debugging.js");
|
|
@@ -24,16 +24,11 @@ const makeDefaultLoader = (from) => {
|
|
|
24
24
|
}
|
|
25
25
|
const relativeRequire = (0, module_1.createRequire)(from);
|
|
26
26
|
return async (mod) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
**/
|
|
33
|
-
// FIXME(pnpm-update): this causes dev-test devDeps to be brought into CLI's package.json, which is not ideal.
|
|
34
|
-
// Note that `relativeRequire.resolve(mod)` seems to work correctly for ESM as well.
|
|
35
|
-
mod
|
|
36
|
-
: relativeRequire.resolve(mod)}`).then(s => tslib_1.__importStar(require(s)));
|
|
27
|
+
// `import()` always goes through Node's ESM resolver, so a resolved absolute
|
|
28
|
+
// filename must be converted to a `file://` URL first -- on Windows, a raw
|
|
29
|
+
// `C:\\...` path is parsed as a URL with an (invalid) `c:` protocol otherwise.
|
|
30
|
+
const resolved = relativeRequire.resolve(mod);
|
|
31
|
+
return Promise.resolve(`${(0, url_1.pathToFileURL)(resolved).href}`).then(s => tslib_1.__importStar(require(s)));
|
|
37
32
|
};
|
|
38
33
|
};
|
|
39
34
|
function createCache() {
|
package/cjs/config.js
CHANGED
|
@@ -23,7 +23,6 @@ const yaml_1 = tslib_1.__importDefault(require("yaml"));
|
|
|
23
23
|
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
24
24
|
const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
|
|
25
25
|
const graphql_config_js_1 = require("./graphql-config.js");
|
|
26
|
-
const isESMModule_js_1 = require("./isESMModule.js");
|
|
27
26
|
const load_js_1 = require("./load.js");
|
|
28
27
|
const version_js_1 = require("./version.js");
|
|
29
28
|
const { lstat } = fs_1.promises;
|
|
@@ -383,18 +382,12 @@ async function addMetadataToSources(documentFilesPromise, type) {
|
|
|
383
382
|
* `safeDynamicImport` is a wrapper of dynamic `import()`
|
|
384
383
|
* to work across Linux and Windows
|
|
385
384
|
*
|
|
386
|
-
* CJS
|
|
387
|
-
* `import()` seems to work well in CJS when given resolved filename
|
|
388
|
-
*
|
|
389
|
-
* ESM:
|
|
385
|
+
* `import()` always goes through Node's ESM resolver, in both CJS and ESM callers.
|
|
390
386
|
* On native Windows (i.e. no WSL or CI), filename may look like this: `C:\\Users\\path\\to\\file.ts`
|
|
391
387
|
* If used directly with `import()`, we'll see `ERR_UNSUPPORTED_ESM_URL_SCHEME` error because `c:` is not a valid protocol
|
|
392
388
|
* `url.pathToFileURL` turns the filename to `file:///C:/Users/path/to/file.ts`, which is import-able
|
|
393
389
|
*/
|
|
394
390
|
const safeDynamicImport = (absoluteFilename) => {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
return Promise.resolve(`${fileUrl}`).then(s => tslib_1.__importStar(require(s)));
|
|
398
|
-
}
|
|
399
|
-
return Promise.resolve(`${absoluteFilename}`).then(s => tslib_1.__importStar(require(s)));
|
|
391
|
+
const { href: fileUrl } = url.pathToFileURL(absoluteFilename);
|
|
392
|
+
return Promise.resolve(`${fileUrl}`).then(s => tslib_1.__importStar(require(s)));
|
|
400
393
|
};
|
package/cjs/utils/watcher.js
CHANGED
|
@@ -89,12 +89,17 @@ afterRun = () => Promise.resolve()) => {
|
|
|
89
89
|
config: (0, plugin_helpers_1.normalizeOutputParam)(config.generates[filename]),
|
|
90
90
|
}))) {
|
|
91
91
|
// ParcelWatcher expects relative ignore patterns to be relative from watchDirectory,
|
|
92
|
-
// but we expect filename from config to be relative from cwd, so we need to convert
|
|
93
|
-
|
|
92
|
+
// but we expect filename from config to be relative from cwd, so we need to convert.
|
|
93
|
+
// NOTE: `relative()` uses the native path separator, but ignore patterns are glob
|
|
94
|
+
// patterns, which must use `/` regardless of OS (backslash is the glob escape
|
|
95
|
+
// character), so normalize to `/` here rather than joining with `join()`.
|
|
96
|
+
const filenameRelativeFromWatchDirectory = (0, path_1.relative)(watchDirectory, (0, path_1.resolve)(process.cwd(), entry.filename))
|
|
97
|
+
.split(path_1.sep)
|
|
98
|
+
.join('/');
|
|
94
99
|
if (entry.config.preset) {
|
|
95
100
|
const extension = entry.config.presetConfig?.extension;
|
|
96
101
|
if (extension) {
|
|
97
|
-
ignored.push(
|
|
102
|
+
ignored.push(`${filenameRelativeFromWatchDirectory}/**/*${extension}`);
|
|
98
103
|
}
|
|
99
104
|
}
|
|
100
105
|
else {
|
package/cjs/version.js
CHANGED
package/esm/codegen.js
CHANGED
|
@@ -2,6 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
import { cpus } from 'os';
|
|
4
4
|
import path from 'path';
|
|
5
|
+
import { pathToFileURL } from 'url';
|
|
5
6
|
import { buildASTSchema, GraphQLError, isSchema } from 'graphql';
|
|
6
7
|
import { Listr } from 'listr2';
|
|
7
8
|
import { codegen } from '@graphql-codegen/core';
|
|
@@ -10,7 +11,6 @@ import { NoTypeDefinitionsFound } from '@graphql-tools/load';
|
|
|
10
11
|
import { mergeTypeDefs } from '@graphql-tools/merge';
|
|
11
12
|
import { ensureContext } from './config.js';
|
|
12
13
|
import { getDocumentTransform } from './documentTransforms.js';
|
|
13
|
-
import { isESMModule } from './isESMModule.js';
|
|
14
14
|
import { getPluginByName } from './plugins.js';
|
|
15
15
|
import { getPresetByName } from './presets.js';
|
|
16
16
|
import { debugLog, printLogs } from './utils/debugging.js';
|
|
@@ -20,16 +20,11 @@ const makeDefaultLoader = (from) => {
|
|
|
20
20
|
}
|
|
21
21
|
const relativeRequire = createRequire(from);
|
|
22
22
|
return async (mod) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
**/
|
|
29
|
-
// FIXME(pnpm-update): this causes dev-test devDeps to be brought into CLI's package.json, which is not ideal.
|
|
30
|
-
// Note that `relativeRequire.resolve(mod)` seems to work correctly for ESM as well.
|
|
31
|
-
mod
|
|
32
|
-
: relativeRequire.resolve(mod));
|
|
23
|
+
// `import()` always goes through Node's ESM resolver, so a resolved absolute
|
|
24
|
+
// filename must be converted to a `file://` URL first -- on Windows, a raw
|
|
25
|
+
// `C:\\...` path is parsed as a URL with an (invalid) `c:` protocol otherwise.
|
|
26
|
+
const resolved = relativeRequire.resolve(mod);
|
|
27
|
+
return import(pathToFileURL(resolved).href);
|
|
33
28
|
};
|
|
34
29
|
};
|
|
35
30
|
function createCache() {
|
package/esm/config.js
CHANGED
|
@@ -11,7 +11,6 @@ import yaml from 'yaml';
|
|
|
11
11
|
import yargs from 'yargs';
|
|
12
12
|
import { createNoopProfiler, createProfiler, getCachedDocumentNodeFromSchema, } from '@graphql-codegen/plugin-helpers';
|
|
13
13
|
import { findAndLoadGraphQLConfig } from './graphql-config.js';
|
|
14
|
-
import { isESMModule } from './isESMModule.js';
|
|
15
14
|
import { defaultDocumentsLoadOptions, defaultSchemaLoadOptions, loadDocuments, loadSchema, } from './load.js';
|
|
16
15
|
import { version } from './version.js';
|
|
17
16
|
const { lstat } = promises;
|
|
@@ -370,18 +369,12 @@ async function addMetadataToSources(documentFilesPromise, type) {
|
|
|
370
369
|
* `safeDynamicImport` is a wrapper of dynamic `import()`
|
|
371
370
|
* to work across Linux and Windows
|
|
372
371
|
*
|
|
373
|
-
* CJS
|
|
374
|
-
* `import()` seems to work well in CJS when given resolved filename
|
|
375
|
-
*
|
|
376
|
-
* ESM:
|
|
372
|
+
* `import()` always goes through Node's ESM resolver, in both CJS and ESM callers.
|
|
377
373
|
* On native Windows (i.e. no WSL or CI), filename may look like this: `C:\\Users\\path\\to\\file.ts`
|
|
378
374
|
* If used directly with `import()`, we'll see `ERR_UNSUPPORTED_ESM_URL_SCHEME` error because `c:` is not a valid protocol
|
|
379
375
|
* `url.pathToFileURL` turns the filename to `file:///C:/Users/path/to/file.ts`, which is import-able
|
|
380
376
|
*/
|
|
381
377
|
const safeDynamicImport = (absoluteFilename) => {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
return import(fileUrl);
|
|
385
|
-
}
|
|
386
|
-
return import(absoluteFilename);
|
|
378
|
+
const { href: fileUrl } = url.pathToFileURL(absoluteFilename);
|
|
379
|
+
return import(fileUrl);
|
|
387
380
|
};
|
package/esm/utils/watcher.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isAbsolute,
|
|
1
|
+
import { isAbsolute, relative, resolve, sep } from 'path';
|
|
2
2
|
import debounce from 'debounce';
|
|
3
3
|
import logSymbols from 'log-symbols';
|
|
4
4
|
import mm from 'micromatch';
|
|
@@ -85,12 +85,17 @@ afterRun = () => Promise.resolve()) => {
|
|
|
85
85
|
config: normalizeOutputParam(config.generates[filename]),
|
|
86
86
|
}))) {
|
|
87
87
|
// ParcelWatcher expects relative ignore patterns to be relative from watchDirectory,
|
|
88
|
-
// but we expect filename from config to be relative from cwd, so we need to convert
|
|
89
|
-
|
|
88
|
+
// but we expect filename from config to be relative from cwd, so we need to convert.
|
|
89
|
+
// NOTE: `relative()` uses the native path separator, but ignore patterns are glob
|
|
90
|
+
// patterns, which must use `/` regardless of OS (backslash is the glob escape
|
|
91
|
+
// character), so normalize to `/` here rather than joining with `join()`.
|
|
92
|
+
const filenameRelativeFromWatchDirectory = relative(watchDirectory, resolve(process.cwd(), entry.filename))
|
|
93
|
+
.split(sep)
|
|
94
|
+
.join('/');
|
|
90
95
|
if (entry.config.preset) {
|
|
91
96
|
const extension = entry.config.presetConfig?.extension;
|
|
92
97
|
if (extension) {
|
|
93
|
-
ignored.push(
|
|
98
|
+
ignored.push(`${filenameRelativeFromWatchDirectory}/**/*${extension}`);
|
|
94
99
|
}
|
|
95
100
|
}
|
|
96
101
|
else {
|
package/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '7.4.
|
|
1
|
+
export const version = '7.4.1-alpha-20260906052927-fb05cdd753213e6c67cf8cb80fc55a6d47eaecfb';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.1-alpha-20260906052927-fb05cdd753213e6c67cf8cb80fc55a6d47eaecfb",
|
|
4
4
|
"peerDependenciesMeta": {
|
|
5
5
|
"@parcel/watcher": {
|
|
6
6
|
"optional": true
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"tslib": "^2.4.0",
|
|
44
44
|
"yaml": "^2.3.1",
|
|
45
45
|
"yargs": "^18.0.0",
|
|
46
|
+
"@graphql-codegen/plugin-helpers": "^7.3.0",
|
|
46
47
|
"@graphql-codegen/client-preset": "^6.1.3",
|
|
47
|
-
"@graphql-codegen/core": "^6.2.0"
|
|
48
|
-
"@graphql-codegen/plugin-helpers": "^7.3.0"
|
|
48
|
+
"@graphql-codegen/core": "^6.2.0"
|
|
49
49
|
},
|
|
50
50
|
"repository": {
|
|
51
51
|
"type": "git",
|