@graphql-codegen/cli 2.3.0-alpha-166ea3cc1.0 → 2.4.0-alpha-6cdbcf02e.0

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/bin.js CHANGED
@@ -505,19 +505,34 @@ async function loadSchema(schemaPointers, config) {
505
505
 
506
506
  ${e.message || e}
507
507
  ${e.stack || ''}
508
-
508
+
509
509
  GraphQL Code Generator supports:
510
510
  - ES Modules and CommonJS exports (export as default or named export "schema")
511
511
  - Introspection JSON File
512
512
  - URL of GraphQL endpoint
513
513
  - Multiple files with type definitions (glob expression)
514
514
  - String in config file
515
-
515
+
516
516
  Try to use one of above options and run codegen again.
517
-
517
+
518
518
  `);
519
519
  }
520
520
  }
521
+ const adjustRequirePointers = (documentPointers) => {
522
+ const adjustSinglePointer = (pointer) => {
523
+ if (typeof pointer === 'object' && 'require' in pointer) {
524
+ const config = 'config' in pointer ? pointer.config : {};
525
+ return { [pointer['require']]: config };
526
+ }
527
+ return pointer;
528
+ };
529
+ if (Array.isArray(documentPointers)) {
530
+ return documentPointers.map(adjustSinglePointer);
531
+ }
532
+ else {
533
+ return adjustSinglePointer(documentPointers);
534
+ }
535
+ };
521
536
  async function loadDocuments(documentPointers, config) {
522
537
  const loaders = [
523
538
  new codeFileLoader.CodeFileLoader({
@@ -537,7 +552,7 @@ async function loadDocuments(documentPointers, config) {
537
552
  }
538
553
  ignore.push(path.join(process.cwd(), generatePath));
539
554
  }
540
- const loadedFromToolkit = await load.loadDocuments(documentPointers, {
555
+ const loadedFromToolkit = await load.loadDocuments(adjustRequirePointers(documentPointers), {
541
556
  ...defaultDocumentsLoadOptions,
542
557
  ignore,
543
558
  loaders,
package/config.d.ts CHANGED
@@ -10,6 +10,7 @@ export declare type YamlCliFlags = {
10
10
  silent: boolean;
11
11
  errorsOnly: boolean;
12
12
  };
13
+ export declare function generateSearchPlaces(moduleName: string): string[];
13
14
  export interface LoadCodegenConfigOptions {
14
15
  /**
15
16
  * The path to the config file or directory contains the config file.
package/index.js CHANGED
@@ -423,19 +423,34 @@ async function loadSchema(schemaPointers, config) {
423
423
 
424
424
  ${e.message || e}
425
425
  ${e.stack || ''}
426
-
426
+
427
427
  GraphQL Code Generator supports:
428
428
  - ES Modules and CommonJS exports (export as default or named export "schema")
429
429
  - Introspection JSON File
430
430
  - URL of GraphQL endpoint
431
431
  - Multiple files with type definitions (glob expression)
432
432
  - String in config file
433
-
433
+
434
434
  Try to use one of above options and run codegen again.
435
-
435
+
436
436
  `);
437
437
  }
438
438
  }
439
+ const adjustRequirePointers = (documentPointers) => {
440
+ const adjustSinglePointer = (pointer) => {
441
+ if (typeof pointer === 'object' && 'require' in pointer) {
442
+ const config = 'config' in pointer ? pointer.config : {};
443
+ return { [pointer['require']]: config };
444
+ }
445
+ return pointer;
446
+ };
447
+ if (Array.isArray(documentPointers)) {
448
+ return documentPointers.map(adjustSinglePointer);
449
+ }
450
+ else {
451
+ return adjustSinglePointer(documentPointers);
452
+ }
453
+ };
439
454
  async function loadDocuments(documentPointers, config) {
440
455
  const loaders = [
441
456
  new codeFileLoader.CodeFileLoader({
@@ -455,7 +470,7 @@ async function loadDocuments(documentPointers, config) {
455
470
  }
456
471
  ignore.push(path.join(process.cwd(), generatePath));
457
472
  }
458
- const loadedFromToolkit = await load.loadDocuments(documentPointers, {
473
+ const loadedFromToolkit = await load.loadDocuments(adjustRequirePointers(documentPointers), {
459
474
  ...defaultDocumentsLoadOptions,
460
475
  ignore,
461
476
  loaders,
@@ -1786,6 +1801,7 @@ exports.ensureGraphQlPackage = ensureGraphQlPackage;
1786
1801
  exports.executeCodegen = executeCodegen;
1787
1802
  exports.findAndLoadGraphQLConfig = findAndLoadGraphQLConfig;
1788
1803
  exports.generate = generate;
1804
+ exports.generateSearchPlaces = generateSearchPlaces;
1789
1805
  exports.init = init;
1790
1806
  exports.loadCodegenConfig = loadCodegenConfig;
1791
1807
  exports.loadContext = loadContext;
package/index.mjs CHANGED
@@ -396,19 +396,34 @@ async function loadSchema(schemaPointers, config) {
396
396
 
397
397
  ${e.message || e}
398
398
  ${e.stack || ''}
399
-
399
+
400
400
  GraphQL Code Generator supports:
401
401
  - ES Modules and CommonJS exports (export as default or named export "schema")
402
402
  - Introspection JSON File
403
403
  - URL of GraphQL endpoint
404
404
  - Multiple files with type definitions (glob expression)
405
405
  - String in config file
406
-
406
+
407
407
  Try to use one of above options and run codegen again.
408
-
408
+
409
409
  `);
410
410
  }
411
411
  }
412
+ const adjustRequirePointers = (documentPointers) => {
413
+ const adjustSinglePointer = (pointer) => {
414
+ if (typeof pointer === 'object' && 'require' in pointer) {
415
+ const config = 'config' in pointer ? pointer.config : {};
416
+ return { [pointer['require']]: config };
417
+ }
418
+ return pointer;
419
+ };
420
+ if (Array.isArray(documentPointers)) {
421
+ return documentPointers.map(adjustSinglePointer);
422
+ }
423
+ else {
424
+ return adjustSinglePointer(documentPointers);
425
+ }
426
+ };
412
427
  async function loadDocuments(documentPointers, config) {
413
428
  const loaders = [
414
429
  new CodeFileLoader({
@@ -428,7 +443,7 @@ async function loadDocuments(documentPointers, config) {
428
443
  }
429
444
  ignore.push(join(process.cwd(), generatePath));
430
445
  }
431
- const loadedFromToolkit = await loadDocuments$1(documentPointers, {
446
+ const loadedFromToolkit = await loadDocuments$1(adjustRequirePointers(documentPointers), {
432
447
  ...defaultDocumentsLoadOptions,
433
448
  ignore,
434
449
  loaders,
@@ -1749,4 +1764,4 @@ async function ensureGraphQlPackage() {
1749
1764
  }
1750
1765
  }
1751
1766
 
1752
- export { CodegenContext, CodegenExtension, buildOptions, cliError, createContext, ensureContext, ensureGraphQlPackage, executeCodegen, findAndLoadGraphQLConfig, generate, init, loadCodegenConfig, loadContext, parseArgv, runCli, updateContextWithCliFlags };
1767
+ export { CodegenContext, CodegenExtension, buildOptions, cliError, createContext, ensureContext, ensureGraphQlPackage, executeCodegen, findAndLoadGraphQLConfig, generate, generateSearchPlaces, init, loadCodegenConfig, loadContext, parseArgv, runCli, updateContextWithCliFlags };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@graphql-codegen/cli",
3
- "version": "2.3.0-alpha-166ea3cc1.0",
3
+ "version": "2.4.0-alpha-6cdbcf02e.0",
4
4
  "peerDependencies": {
5
- "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"
5
+ "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
6
  },
7
7
  "dependencies": {
8
- "@graphql-codegen/core": "2.2.0",
9
- "@graphql-codegen/plugin-helpers": "^2.2.0",
8
+ "@graphql-codegen/core": "2.4.1-alpha-6cdbcf02e.0",
9
+ "@graphql-codegen/plugin-helpers": "2.3.3-alpha-6cdbcf02e.0",
10
10
  "@graphql-tools/apollo-engine-loader": "^7.0.5",
11
11
  "@graphql-tools/code-file-loader": "^7.0.6",
12
12
  "@graphql-tools/git-loader": "^7.0.5",
@@ -28,8 +28,8 @@
28
28
  "detect-indent": "^6.0.0",
29
29
  "glob": "^7.1.6",
30
30
  "globby": "^11.0.4",
31
- "graphql-config": "^4.0.1",
32
- "inquirer": "^7.3.3",
31
+ "graphql-config": "^4.1.0",
32
+ "inquirer": "^8.0.0",
33
33
  "is-glob": "^4.0.1",
34
34
  "json-to-pretty-yaml": "^1.2.2",
35
35
  "latest-version": "5.1.0",
@@ -78,6 +78,7 @@
78
78
  "definition": "index.d.ts"
79
79
  },
80
80
  "exports": {
81
+ "./package.json": "./package.json",
81
82
  ".": {
82
83
  "require": "./index.js",
83
84
  "import": "./index.mjs"