@graphql-codegen/cli 2.4.0 → 2.4.1-alpha-7b61b3baf.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.
Files changed (4) hide show
  1. package/bin.js +21 -0
  2. package/index.js +21 -0
  3. package/index.mjs +21 -0
  4. package/package.json +2 -1
package/bin.js CHANGED
@@ -35,6 +35,7 @@ const wrapAnsi = _interopDefault(require('wrap-ansi'));
35
35
  const commonTags = require('common-tags');
36
36
  const UpdateRenderer = _interopDefault(require('listr-update-renderer'));
37
37
  const graphql = require('graphql');
38
+ const tslib = require('tslib');
38
39
  const cosmiconfig = require('cosmiconfig');
39
40
  const stringEnvInterpolation = require('string-env-interpolation');
40
41
  const yargs = _interopDefault(require('yargs'));
@@ -52,6 +53,7 @@ const yaml = _interopDefault(require('yaml'));
52
53
  const module$1 = require('module');
53
54
  const fs = require('fs');
54
55
  const fs__default = _interopDefault(fs);
56
+ const buddy = require('@theguild/buddy');
55
57
  const Listr = _interopDefault(require('listr'));
56
58
  const isGlob = _interopDefault(require('is-glob'));
57
59
  const debounce = _interopDefault(require('debounce'));
@@ -759,6 +761,7 @@ class CodegenContext {
759
761
  getPluginContext() {
760
762
  return this._pluginContext;
761
763
  }
764
+ // [ ] This will break watch mode - cache forever
762
765
  async loadSchema(pointer) {
763
766
  const config = this.getConfig(defaultSchemaLoadOptions);
764
767
  if (this._graphqlConfig) {
@@ -767,6 +770,7 @@ class CodegenContext {
767
770
  }
768
771
  return loadSchema(pointer, config);
769
772
  }
773
+ // [ ] This will break watch mode - cache forever
770
774
  async loadDocuments(pointer) {
771
775
  const config = this.getConfig(defaultDocumentsLoadOptions);
772
776
  if (this._graphqlConfig) {
@@ -777,9 +781,26 @@ class CodegenContext {
777
781
  return loadDocuments(pointer, config);
778
782
  }
779
783
  }
784
+ tslib.__decorate([
785
+ buddy.cacheResult(cacheKeyFactory()),
786
+ tslib.__metadata("design:type", Function),
787
+ tslib.__metadata("design:paramtypes", [Object]),
788
+ tslib.__metadata("design:returntype", Promise)
789
+ ], CodegenContext.prototype, "loadSchema", null);
790
+ tslib.__decorate([
791
+ buddy.cacheResult(cacheKeyFactory()),
792
+ tslib.__metadata("design:type", Function),
793
+ tslib.__metadata("design:paramtypes", [Array]),
794
+ tslib.__metadata("design:returntype", Promise)
795
+ ], CodegenContext.prototype, "loadDocuments", null);
780
796
  function ensureContext(input) {
781
797
  return input instanceof CodegenContext ? input : new CodegenContext({ config: input });
782
798
  }
799
+ function cacheKeyFactory() {
800
+ return function stringifyPointer(value) {
801
+ return JSON.stringify(value);
802
+ };
803
+ }
783
804
 
784
805
  const makeDefaultLoader = (from) => {
785
806
  if (fs__default.statSync(from).isDirectory()) {
package/index.js CHANGED
@@ -35,6 +35,7 @@ const UpdateRenderer = _interopDefault(require('listr-update-renderer'));
35
35
  const graphql = require('graphql');
36
36
  const path = require('path');
37
37
  const path__default = _interopDefault(path);
38
+ const tslib = require('tslib');
38
39
  const cosmiconfig = require('cosmiconfig');
39
40
  const stringEnvInterpolation = require('string-env-interpolation');
40
41
  const yargs = _interopDefault(require('yargs'));
@@ -52,6 +53,7 @@ const yaml = _interopDefault(require('yaml'));
52
53
  const module$1 = require('module');
53
54
  const fs = require('fs');
54
55
  const fs__default = _interopDefault(fs);
56
+ const buddy = require('@theguild/buddy');
55
57
  const Listr = _interopDefault(require('listr'));
56
58
  const child_process = require('child_process');
57
59
  const isGlob = _interopDefault(require('is-glob'));
@@ -677,6 +679,7 @@ class CodegenContext {
677
679
  getPluginContext() {
678
680
  return this._pluginContext;
679
681
  }
682
+ // [ ] This will break watch mode - cache forever
680
683
  async loadSchema(pointer) {
681
684
  const config = this.getConfig(defaultSchemaLoadOptions);
682
685
  if (this._graphqlConfig) {
@@ -685,6 +688,7 @@ class CodegenContext {
685
688
  }
686
689
  return loadSchema(pointer, config);
687
690
  }
691
+ // [ ] This will break watch mode - cache forever
688
692
  async loadDocuments(pointer) {
689
693
  const config = this.getConfig(defaultDocumentsLoadOptions);
690
694
  if (this._graphqlConfig) {
@@ -695,9 +699,26 @@ class CodegenContext {
695
699
  return loadDocuments(pointer, config);
696
700
  }
697
701
  }
702
+ tslib.__decorate([
703
+ buddy.cacheResult(cacheKeyFactory()),
704
+ tslib.__metadata("design:type", Function),
705
+ tslib.__metadata("design:paramtypes", [Object]),
706
+ tslib.__metadata("design:returntype", Promise)
707
+ ], CodegenContext.prototype, "loadSchema", null);
708
+ tslib.__decorate([
709
+ buddy.cacheResult(cacheKeyFactory()),
710
+ tslib.__metadata("design:type", Function),
711
+ tslib.__metadata("design:paramtypes", [Array]),
712
+ tslib.__metadata("design:returntype", Promise)
713
+ ], CodegenContext.prototype, "loadDocuments", null);
698
714
  function ensureContext(input) {
699
715
  return input instanceof CodegenContext ? input : new CodegenContext({ config: input });
700
716
  }
717
+ function cacheKeyFactory() {
718
+ return function stringifyPointer(value) {
719
+ return JSON.stringify(value);
720
+ };
721
+ }
701
722
 
702
723
  const makeDefaultLoader = (from) => {
703
724
  if (fs__default.statSync(from).isDirectory()) {
package/index.mjs CHANGED
@@ -9,6 +9,7 @@ import { dummyLogger } from 'ts-log';
9
9
  import UpdateRenderer from 'listr-update-renderer';
10
10
  import { GraphQLError } from 'graphql';
11
11
  import path, { resolve, extname, join, delimiter, sep, dirname, isAbsolute, relative } from 'path';
12
+ import { __decorate, __metadata } from 'tslib';
12
13
  import { cosmiconfig, defaultLoaders } from 'cosmiconfig';
13
14
  import { env } from 'string-env-interpolation';
14
15
  import yargs from 'yargs';
@@ -25,6 +26,7 @@ import { UrlLoader } from '@graphql-tools/url-loader';
25
26
  import yaml from 'yaml';
26
27
  import { createRequire } from 'module';
27
28
  import fs, { promises, readFileSync, writeFileSync, statSync, unlink } from 'fs';
29
+ import { cacheResult } from '@theguild/buddy';
28
30
  import Listr from 'listr';
29
31
  import { exec } from 'child_process';
30
32
  import isGlob from 'is-glob';
@@ -650,6 +652,7 @@ class CodegenContext {
650
652
  getPluginContext() {
651
653
  return this._pluginContext;
652
654
  }
655
+ // [ ] This will break watch mode - cache forever
653
656
  async loadSchema(pointer) {
654
657
  const config = this.getConfig(defaultSchemaLoadOptions);
655
658
  if (this._graphqlConfig) {
@@ -658,6 +661,7 @@ class CodegenContext {
658
661
  }
659
662
  return loadSchema(pointer, config);
660
663
  }
664
+ // [ ] This will break watch mode - cache forever
661
665
  async loadDocuments(pointer) {
662
666
  const config = this.getConfig(defaultDocumentsLoadOptions);
663
667
  if (this._graphqlConfig) {
@@ -668,9 +672,26 @@ class CodegenContext {
668
672
  return loadDocuments(pointer, config);
669
673
  }
670
674
  }
675
+ __decorate([
676
+ cacheResult(cacheKeyFactory()),
677
+ __metadata("design:type", Function),
678
+ __metadata("design:paramtypes", [Object]),
679
+ __metadata("design:returntype", Promise)
680
+ ], CodegenContext.prototype, "loadSchema", null);
681
+ __decorate([
682
+ cacheResult(cacheKeyFactory()),
683
+ __metadata("design:type", Function),
684
+ __metadata("design:paramtypes", [Array]),
685
+ __metadata("design:returntype", Promise)
686
+ ], CodegenContext.prototype, "loadDocuments", null);
671
687
  function ensureContext(input) {
672
688
  return input instanceof CodegenContext ? input : new CodegenContext({ config: input });
673
689
  }
690
+ function cacheKeyFactory() {
691
+ return function stringifyPointer(value) {
692
+ return JSON.stringify(value);
693
+ };
694
+ }
674
695
 
675
696
  const makeDefaultLoader = (from) => {
676
697
  if (fs.statSync(from).isDirectory()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/cli",
3
- "version": "2.4.0",
3
+ "version": "2.4.1-alpha-7b61b3baf.0",
4
4
  "peerDependencies": {
5
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
  },
@@ -17,6 +17,7 @@
17
17
  "@graphql-tools/prisma-loader": "^7.0.6",
18
18
  "@graphql-tools/url-loader": "^7.0.11",
19
19
  "@graphql-tools/utils": "^8.1.1",
20
+ "@theguild/buddy": "0.1.0",
20
21
  "ansi-escapes": "^4.3.1",
21
22
  "chalk": "^4.1.0",
22
23
  "change-case-all": "1.0.14",