@graphql-codegen/cli 2.4.1-alpha-7b61b3baf.0 → 2.4.1-alpha-05252ae4a.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 +7 -25
  2. package/index.js +7 -25
  3. package/index.mjs +7 -25
  4. package/package.json +1 -2
package/bin.js CHANGED
@@ -35,7 +35,6 @@ 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');
39
38
  const cosmiconfig = require('cosmiconfig');
40
39
  const stringEnvInterpolation = require('string-env-interpolation');
41
40
  const yargs = _interopDefault(require('yargs'));
@@ -53,7 +52,6 @@ const yaml = _interopDefault(require('yaml'));
53
52
  const module$1 = require('module');
54
53
  const fs = require('fs');
55
54
  const fs__default = _interopDefault(fs);
56
- const buddy = require('@theguild/buddy');
57
55
  const Listr = _interopDefault(require('listr'));
58
56
  const isGlob = _interopDefault(require('is-glob'));
59
57
  const debounce = _interopDefault(require('debounce'));
@@ -761,7 +759,6 @@ class CodegenContext {
761
759
  getPluginContext() {
762
760
  return this._pluginContext;
763
761
  }
764
- // [ ] This will break watch mode - cache forever
765
762
  async loadSchema(pointer) {
766
763
  const config = this.getConfig(defaultSchemaLoadOptions);
767
764
  if (this._graphqlConfig) {
@@ -770,7 +767,6 @@ class CodegenContext {
770
767
  }
771
768
  return loadSchema(pointer, config);
772
769
  }
773
- // [ ] This will break watch mode - cache forever
774
770
  async loadDocuments(pointer) {
775
771
  const config = this.getConfig(defaultDocumentsLoadOptions);
776
772
  if (this._graphqlConfig) {
@@ -781,26 +777,9 @@ class CodegenContext {
781
777
  return loadDocuments(pointer, config);
782
778
  }
783
779
  }
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);
796
780
  function ensureContext(input) {
797
781
  return input instanceof CodegenContext ? input : new CodegenContext({ config: input });
798
782
  }
799
- function cacheKeyFactory() {
800
- return function stringifyPointer(value) {
801
- return JSON.stringify(value);
802
- };
803
- }
804
783
 
805
784
  const makeDefaultLoader = (from) => {
806
785
  if (fs__default.statSync(from).isDirectory()) {
@@ -999,10 +978,13 @@ async function executeCodegen(input) {
999
978
  title: 'Load GraphQL documents',
1000
979
  task: wrapTask(async () => {
1001
980
  debugLog(`[CLI] Loading Documents`);
1002
- const allDocuments = [...rootDocuments, ...outputSpecificDocuments];
1003
- const hash = JSON.stringify(allDocuments);
1004
- const result = await documentsLoadingCache.load(hash);
1005
- const documents = result.documents;
981
+ // get different cache for shared docs and output specific docs
982
+ const results = await Promise.all([rootDocuments, outputSpecificDocuments].map(docs => {
983
+ const hash = JSON.stringify(docs);
984
+ return documentsLoadingCache.load(hash);
985
+ }));
986
+ const documents = [];
987
+ results.forEach(source => documents.push(...source.documents));
1006
988
  if (documents.length > 0) {
1007
989
  outputDocuments.push(...documents);
1008
990
  }
package/index.js CHANGED
@@ -35,7 +35,6 @@ 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');
39
38
  const cosmiconfig = require('cosmiconfig');
40
39
  const stringEnvInterpolation = require('string-env-interpolation');
41
40
  const yargs = _interopDefault(require('yargs'));
@@ -53,7 +52,6 @@ const yaml = _interopDefault(require('yaml'));
53
52
  const module$1 = require('module');
54
53
  const fs = require('fs');
55
54
  const fs__default = _interopDefault(fs);
56
- const buddy = require('@theguild/buddy');
57
55
  const Listr = _interopDefault(require('listr'));
58
56
  const child_process = require('child_process');
59
57
  const isGlob = _interopDefault(require('is-glob'));
@@ -679,7 +677,6 @@ class CodegenContext {
679
677
  getPluginContext() {
680
678
  return this._pluginContext;
681
679
  }
682
- // [ ] This will break watch mode - cache forever
683
680
  async loadSchema(pointer) {
684
681
  const config = this.getConfig(defaultSchemaLoadOptions);
685
682
  if (this._graphqlConfig) {
@@ -688,7 +685,6 @@ class CodegenContext {
688
685
  }
689
686
  return loadSchema(pointer, config);
690
687
  }
691
- // [ ] This will break watch mode - cache forever
692
688
  async loadDocuments(pointer) {
693
689
  const config = this.getConfig(defaultDocumentsLoadOptions);
694
690
  if (this._graphqlConfig) {
@@ -699,26 +695,9 @@ class CodegenContext {
699
695
  return loadDocuments(pointer, config);
700
696
  }
701
697
  }
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);
714
698
  function ensureContext(input) {
715
699
  return input instanceof CodegenContext ? input : new CodegenContext({ config: input });
716
700
  }
717
- function cacheKeyFactory() {
718
- return function stringifyPointer(value) {
719
- return JSON.stringify(value);
720
- };
721
- }
722
701
 
723
702
  const makeDefaultLoader = (from) => {
724
703
  if (fs__default.statSync(from).isDirectory()) {
@@ -917,10 +896,13 @@ async function executeCodegen(input) {
917
896
  title: 'Load GraphQL documents',
918
897
  task: wrapTask(async () => {
919
898
  debugLog(`[CLI] Loading Documents`);
920
- const allDocuments = [...rootDocuments, ...outputSpecificDocuments];
921
- const hash = JSON.stringify(allDocuments);
922
- const result = await documentsLoadingCache.load(hash);
923
- const documents = result.documents;
899
+ // get different cache for shared docs and output specific docs
900
+ const results = await Promise.all([rootDocuments, outputSpecificDocuments].map(docs => {
901
+ const hash = JSON.stringify(docs);
902
+ return documentsLoadingCache.load(hash);
903
+ }));
904
+ const documents = [];
905
+ results.forEach(source => documents.push(...source.documents));
924
906
  if (documents.length > 0) {
925
907
  outputDocuments.push(...documents);
926
908
  }
package/index.mjs CHANGED
@@ -9,7 +9,6 @@ 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';
13
12
  import { cosmiconfig, defaultLoaders } from 'cosmiconfig';
14
13
  import { env } from 'string-env-interpolation';
15
14
  import yargs from 'yargs';
@@ -26,7 +25,6 @@ import { UrlLoader } from '@graphql-tools/url-loader';
26
25
  import yaml from 'yaml';
27
26
  import { createRequire } from 'module';
28
27
  import fs, { promises, readFileSync, writeFileSync, statSync, unlink } from 'fs';
29
- import { cacheResult } from '@theguild/buddy';
30
28
  import Listr from 'listr';
31
29
  import { exec } from 'child_process';
32
30
  import isGlob from 'is-glob';
@@ -652,7 +650,6 @@ class CodegenContext {
652
650
  getPluginContext() {
653
651
  return this._pluginContext;
654
652
  }
655
- // [ ] This will break watch mode - cache forever
656
653
  async loadSchema(pointer) {
657
654
  const config = this.getConfig(defaultSchemaLoadOptions);
658
655
  if (this._graphqlConfig) {
@@ -661,7 +658,6 @@ class CodegenContext {
661
658
  }
662
659
  return loadSchema(pointer, config);
663
660
  }
664
- // [ ] This will break watch mode - cache forever
665
661
  async loadDocuments(pointer) {
666
662
  const config = this.getConfig(defaultDocumentsLoadOptions);
667
663
  if (this._graphqlConfig) {
@@ -672,26 +668,9 @@ class CodegenContext {
672
668
  return loadDocuments(pointer, config);
673
669
  }
674
670
  }
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);
687
671
  function ensureContext(input) {
688
672
  return input instanceof CodegenContext ? input : new CodegenContext({ config: input });
689
673
  }
690
- function cacheKeyFactory() {
691
- return function stringifyPointer(value) {
692
- return JSON.stringify(value);
693
- };
694
- }
695
674
 
696
675
  const makeDefaultLoader = (from) => {
697
676
  if (fs.statSync(from).isDirectory()) {
@@ -890,10 +869,13 @@ async function executeCodegen(input) {
890
869
  title: 'Load GraphQL documents',
891
870
  task: wrapTask(async () => {
892
871
  debugLog(`[CLI] Loading Documents`);
893
- const allDocuments = [...rootDocuments, ...outputSpecificDocuments];
894
- const hash = JSON.stringify(allDocuments);
895
- const result = await documentsLoadingCache.load(hash);
896
- const documents = result.documents;
872
+ // get different cache for shared docs and output specific docs
873
+ const results = await Promise.all([rootDocuments, outputSpecificDocuments].map(docs => {
874
+ const hash = JSON.stringify(docs);
875
+ return documentsLoadingCache.load(hash);
876
+ }));
877
+ const documents = [];
878
+ results.forEach(source => documents.push(...source.documents));
897
879
  if (documents.length > 0) {
898
880
  outputDocuments.push(...documents);
899
881
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/cli",
3
- "version": "2.4.1-alpha-7b61b3baf.0",
3
+ "version": "2.4.1-alpha-05252ae4a.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,7 +17,6 @@
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",
21
20
  "ansi-escapes": "^4.3.1",
22
21
  "chalk": "^4.1.0",
23
22
  "change-case-all": "1.0.14",