@graphql-codegen/cli 2.3.0 → 2.4.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 +35 -3
- package/index.js +35 -3
- package/index.mjs +35 -3
- package/package.json +5 -4
package/bin.js
CHANGED
|
@@ -790,6 +790,20 @@ const makeDefaultLoader = (from) => {
|
|
|
790
790
|
return new Promise(function (resolve) { resolve(_interopNamespace(require(relativeRequire.resolve(mod)))); });
|
|
791
791
|
};
|
|
792
792
|
};
|
|
793
|
+
// TODO: Replace any with types
|
|
794
|
+
function createCache(loader) {
|
|
795
|
+
const cache = new Map();
|
|
796
|
+
return {
|
|
797
|
+
load(key) {
|
|
798
|
+
if (cache.has(key)) {
|
|
799
|
+
return cache.get(key);
|
|
800
|
+
}
|
|
801
|
+
const value = loader(key);
|
|
802
|
+
cache.set(key, value);
|
|
803
|
+
return value;
|
|
804
|
+
},
|
|
805
|
+
};
|
|
806
|
+
}
|
|
793
807
|
async function executeCodegen(input) {
|
|
794
808
|
function wrapTask(task, source) {
|
|
795
809
|
return async () => {
|
|
@@ -839,6 +853,20 @@ async function executeCodegen(input) {
|
|
|
839
853
|
let rootSchemas;
|
|
840
854
|
let rootDocuments;
|
|
841
855
|
const generates = {};
|
|
856
|
+
const schemaLoadingCache = createCache(async function (hash) {
|
|
857
|
+
const outputSchemaAst = await context.loadSchema(JSON.parse(hash));
|
|
858
|
+
const outputSchema = pluginHelpers.getCachedDocumentNodeFromSchema(outputSchemaAst);
|
|
859
|
+
return {
|
|
860
|
+
outputSchemaAst: outputSchemaAst,
|
|
861
|
+
outputSchema: outputSchema,
|
|
862
|
+
};
|
|
863
|
+
});
|
|
864
|
+
const documentsLoadingCache = createCache(async function (hash) {
|
|
865
|
+
const documents = await context.loadDocuments(JSON.parse(hash));
|
|
866
|
+
return {
|
|
867
|
+
documents: documents,
|
|
868
|
+
};
|
|
869
|
+
});
|
|
842
870
|
async function normalize() {
|
|
843
871
|
/* Load Require extensions */
|
|
844
872
|
const requireExtensions = pluginHelpers.normalizeInstanceOrArray(config.require);
|
|
@@ -940,8 +968,10 @@ async function executeCodegen(input) {
|
|
|
940
968
|
Object.assign(schemaPointerMap, unnormalizedPtr);
|
|
941
969
|
}
|
|
942
970
|
}
|
|
943
|
-
|
|
944
|
-
|
|
971
|
+
const hash = JSON.stringify(schemaPointerMap);
|
|
972
|
+
const result = await schemaLoadingCache.load(hash);
|
|
973
|
+
outputSchemaAst = await result.outputSchemaAst;
|
|
974
|
+
outputSchema = result.outputSchema;
|
|
945
975
|
}, filename),
|
|
946
976
|
},
|
|
947
977
|
{
|
|
@@ -949,7 +979,9 @@ async function executeCodegen(input) {
|
|
|
949
979
|
task: wrapTask(async () => {
|
|
950
980
|
debugLog(`[CLI] Loading Documents`);
|
|
951
981
|
const allDocuments = [...rootDocuments, ...outputSpecificDocuments];
|
|
952
|
-
const
|
|
982
|
+
const hash = JSON.stringify(allDocuments);
|
|
983
|
+
const result = await documentsLoadingCache.load(hash);
|
|
984
|
+
const documents = result.documents;
|
|
953
985
|
if (documents.length > 0) {
|
|
954
986
|
outputDocuments.push(...documents);
|
|
955
987
|
}
|
package/index.js
CHANGED
|
@@ -708,6 +708,20 @@ const makeDefaultLoader = (from) => {
|
|
|
708
708
|
return new Promise(function (resolve) { resolve(_interopNamespace(require(relativeRequire.resolve(mod)))); });
|
|
709
709
|
};
|
|
710
710
|
};
|
|
711
|
+
// TODO: Replace any with types
|
|
712
|
+
function createCache(loader) {
|
|
713
|
+
const cache = new Map();
|
|
714
|
+
return {
|
|
715
|
+
load(key) {
|
|
716
|
+
if (cache.has(key)) {
|
|
717
|
+
return cache.get(key);
|
|
718
|
+
}
|
|
719
|
+
const value = loader(key);
|
|
720
|
+
cache.set(key, value);
|
|
721
|
+
return value;
|
|
722
|
+
},
|
|
723
|
+
};
|
|
724
|
+
}
|
|
711
725
|
async function executeCodegen(input) {
|
|
712
726
|
function wrapTask(task, source) {
|
|
713
727
|
return async () => {
|
|
@@ -757,6 +771,20 @@ async function executeCodegen(input) {
|
|
|
757
771
|
let rootSchemas;
|
|
758
772
|
let rootDocuments;
|
|
759
773
|
const generates = {};
|
|
774
|
+
const schemaLoadingCache = createCache(async function (hash) {
|
|
775
|
+
const outputSchemaAst = await context.loadSchema(JSON.parse(hash));
|
|
776
|
+
const outputSchema = pluginHelpers.getCachedDocumentNodeFromSchema(outputSchemaAst);
|
|
777
|
+
return {
|
|
778
|
+
outputSchemaAst: outputSchemaAst,
|
|
779
|
+
outputSchema: outputSchema,
|
|
780
|
+
};
|
|
781
|
+
});
|
|
782
|
+
const documentsLoadingCache = createCache(async function (hash) {
|
|
783
|
+
const documents = await context.loadDocuments(JSON.parse(hash));
|
|
784
|
+
return {
|
|
785
|
+
documents: documents,
|
|
786
|
+
};
|
|
787
|
+
});
|
|
760
788
|
async function normalize() {
|
|
761
789
|
/* Load Require extensions */
|
|
762
790
|
const requireExtensions = pluginHelpers.normalizeInstanceOrArray(config.require);
|
|
@@ -858,8 +886,10 @@ async function executeCodegen(input) {
|
|
|
858
886
|
Object.assign(schemaPointerMap, unnormalizedPtr);
|
|
859
887
|
}
|
|
860
888
|
}
|
|
861
|
-
|
|
862
|
-
|
|
889
|
+
const hash = JSON.stringify(schemaPointerMap);
|
|
890
|
+
const result = await schemaLoadingCache.load(hash);
|
|
891
|
+
outputSchemaAst = await result.outputSchemaAst;
|
|
892
|
+
outputSchema = result.outputSchema;
|
|
863
893
|
}, filename),
|
|
864
894
|
},
|
|
865
895
|
{
|
|
@@ -867,7 +897,9 @@ async function executeCodegen(input) {
|
|
|
867
897
|
task: wrapTask(async () => {
|
|
868
898
|
debugLog(`[CLI] Loading Documents`);
|
|
869
899
|
const allDocuments = [...rootDocuments, ...outputSpecificDocuments];
|
|
870
|
-
const
|
|
900
|
+
const hash = JSON.stringify(allDocuments);
|
|
901
|
+
const result = await documentsLoadingCache.load(hash);
|
|
902
|
+
const documents = result.documents;
|
|
871
903
|
if (documents.length > 0) {
|
|
872
904
|
outputDocuments.push(...documents);
|
|
873
905
|
}
|
package/index.mjs
CHANGED
|
@@ -681,6 +681,20 @@ const makeDefaultLoader = (from) => {
|
|
|
681
681
|
return import(relativeRequire.resolve(mod));
|
|
682
682
|
};
|
|
683
683
|
};
|
|
684
|
+
// TODO: Replace any with types
|
|
685
|
+
function createCache(loader) {
|
|
686
|
+
const cache = new Map();
|
|
687
|
+
return {
|
|
688
|
+
load(key) {
|
|
689
|
+
if (cache.has(key)) {
|
|
690
|
+
return cache.get(key);
|
|
691
|
+
}
|
|
692
|
+
const value = loader(key);
|
|
693
|
+
cache.set(key, value);
|
|
694
|
+
return value;
|
|
695
|
+
},
|
|
696
|
+
};
|
|
697
|
+
}
|
|
684
698
|
async function executeCodegen(input) {
|
|
685
699
|
function wrapTask(task, source) {
|
|
686
700
|
return async () => {
|
|
@@ -730,6 +744,20 @@ async function executeCodegen(input) {
|
|
|
730
744
|
let rootSchemas;
|
|
731
745
|
let rootDocuments;
|
|
732
746
|
const generates = {};
|
|
747
|
+
const schemaLoadingCache = createCache(async function (hash) {
|
|
748
|
+
const outputSchemaAst = await context.loadSchema(JSON.parse(hash));
|
|
749
|
+
const outputSchema = getCachedDocumentNodeFromSchema(outputSchemaAst);
|
|
750
|
+
return {
|
|
751
|
+
outputSchemaAst: outputSchemaAst,
|
|
752
|
+
outputSchema: outputSchema,
|
|
753
|
+
};
|
|
754
|
+
});
|
|
755
|
+
const documentsLoadingCache = createCache(async function (hash) {
|
|
756
|
+
const documents = await context.loadDocuments(JSON.parse(hash));
|
|
757
|
+
return {
|
|
758
|
+
documents: documents,
|
|
759
|
+
};
|
|
760
|
+
});
|
|
733
761
|
async function normalize() {
|
|
734
762
|
/* Load Require extensions */
|
|
735
763
|
const requireExtensions = normalizeInstanceOrArray(config.require);
|
|
@@ -831,8 +859,10 @@ async function executeCodegen(input) {
|
|
|
831
859
|
Object.assign(schemaPointerMap, unnormalizedPtr);
|
|
832
860
|
}
|
|
833
861
|
}
|
|
834
|
-
|
|
835
|
-
|
|
862
|
+
const hash = JSON.stringify(schemaPointerMap);
|
|
863
|
+
const result = await schemaLoadingCache.load(hash);
|
|
864
|
+
outputSchemaAst = await result.outputSchemaAst;
|
|
865
|
+
outputSchema = result.outputSchema;
|
|
836
866
|
}, filename),
|
|
837
867
|
},
|
|
838
868
|
{
|
|
@@ -840,7 +870,9 @@ async function executeCodegen(input) {
|
|
|
840
870
|
task: wrapTask(async () => {
|
|
841
871
|
debugLog(`[CLI] Loading Documents`);
|
|
842
872
|
const allDocuments = [...rootDocuments, ...outputSpecificDocuments];
|
|
843
|
-
const
|
|
873
|
+
const hash = JSON.stringify(allDocuments);
|
|
874
|
+
const result = await documentsLoadingCache.load(hash);
|
|
875
|
+
const documents = result.documents;
|
|
844
876
|
if (documents.length > 0) {
|
|
845
877
|
outputDocuments.push(...documents);
|
|
846
878
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.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
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@graphql-codegen/core": "2.
|
|
9
|
-
"@graphql-codegen/plugin-helpers": "^2.3.
|
|
8
|
+
"@graphql-codegen/core": "2.4.0",
|
|
9
|
+
"@graphql-codegen/plugin-helpers": "^2.3.2",
|
|
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",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"glob": "^7.1.6",
|
|
30
30
|
"globby": "^11.0.4",
|
|
31
31
|
"graphql-config": "^4.1.0",
|
|
32
|
-
"inquirer": "^
|
|
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"
|