@graphql-codegen/cli 2.7.0-alpha-17490f4bb.0 → 2.7.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 +30 -33
- package/index.js +30 -33
- package/index.mjs +30 -33
- package/package.json +7 -14
- package/bin.mjs +0 -1869
- package/utils/is-browser.d.ts +0 -3
- package/utils/try-to-build-schema.d.ts +0 -2
package/bin.js
CHANGED
|
@@ -692,7 +692,7 @@ function buildOptions() {
|
|
|
692
692
|
};
|
|
693
693
|
}
|
|
694
694
|
function parseArgv(argv = process.argv) {
|
|
695
|
-
return yargs
|
|
695
|
+
return yargs.options(buildOptions()).parse(argv);
|
|
696
696
|
}
|
|
697
697
|
async function createContext(cliFlags = parseArgv(process.argv)) {
|
|
698
698
|
if (cliFlags.require && cliFlags.require.length > 0) {
|
|
@@ -830,9 +830,6 @@ function addHashToDocumentFiles(documentFilesPromise) {
|
|
|
830
830
|
}));
|
|
831
831
|
}
|
|
832
832
|
|
|
833
|
-
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
834
|
-
const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
835
|
-
|
|
836
833
|
function isListrError(err) {
|
|
837
834
|
return err.name === 'ListrError' && Array.isArray(err.errors) && err.errors.length > 0;
|
|
838
835
|
}
|
|
@@ -849,12 +846,9 @@ function cliError(err, exitOnError = true) {
|
|
|
849
846
|
}
|
|
850
847
|
// eslint-disable-next-line no-console
|
|
851
848
|
console.error(msg);
|
|
852
|
-
if (exitOnError
|
|
849
|
+
if (exitOnError) {
|
|
853
850
|
process.exit(1);
|
|
854
851
|
}
|
|
855
|
-
else if (exitOnError && isBrowser) {
|
|
856
|
-
throw err;
|
|
857
|
-
}
|
|
858
852
|
}
|
|
859
853
|
|
|
860
854
|
const makeDefaultLoader = (from) => {
|
|
@@ -1014,7 +1008,7 @@ async function executeCodegen(input) {
|
|
|
1014
1008
|
let outputSchemaAst;
|
|
1015
1009
|
let outputSchema;
|
|
1016
1010
|
const outputFileTemplateConfig = outputConfig.config || {};
|
|
1017
|
-
|
|
1011
|
+
let outputDocuments = [];
|
|
1018
1012
|
const outputSpecificSchemas = pluginHelpers.normalizeInstanceOrArray(outputConfig.schema);
|
|
1019
1013
|
const outputSpecificDocuments = pluginHelpers.normalizeInstanceOrArray(outputConfig.documents);
|
|
1020
1014
|
return new Listr([
|
|
@@ -1050,20 +1044,24 @@ async function executeCodegen(input) {
|
|
|
1050
1044
|
task: wrapTask(async () => {
|
|
1051
1045
|
debugLog(`[CLI] Loading Documents`);
|
|
1052
1046
|
// get different cache for shared docs and output specific docs
|
|
1053
|
-
const
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
const documents = [];
|
|
1063
|
-
results.forEach(source => documents.push(...source.documents));
|
|
1064
|
-
if (documents.length > 0) {
|
|
1065
|
-
outputDocuments.push(...documents);
|
|
1047
|
+
const documentPointerMap = {};
|
|
1048
|
+
const allDocumentsUnnormalizedPointers = [...rootDocuments, ...outputSpecificDocuments];
|
|
1049
|
+
for (const unnormalizedPtr of allDocumentsUnnormalizedPointers) {
|
|
1050
|
+
if (typeof unnormalizedPtr === 'string') {
|
|
1051
|
+
documentPointerMap[unnormalizedPtr] = {};
|
|
1052
|
+
}
|
|
1053
|
+
else if (typeof unnormalizedPtr === 'object') {
|
|
1054
|
+
Object.assign(documentPointerMap, unnormalizedPtr);
|
|
1055
|
+
}
|
|
1066
1056
|
}
|
|
1057
|
+
const hash = JSON.stringify(documentPointerMap);
|
|
1058
|
+
const result = await cache('documents', hash, async () => {
|
|
1059
|
+
const documents = await context.loadDocuments(documentPointerMap);
|
|
1060
|
+
return {
|
|
1061
|
+
documents,
|
|
1062
|
+
};
|
|
1063
|
+
});
|
|
1064
|
+
outputDocuments = await result.documents;
|
|
1067
1065
|
}, filename, `Load GraphQL documents: ${filename}`),
|
|
1068
1066
|
},
|
|
1069
1067
|
{
|
|
@@ -1857,17 +1855,16 @@ function addIntrospection(config) {
|
|
|
1857
1855
|
|
|
1858
1856
|
async function runCli(cmd) {
|
|
1859
1857
|
await ensureGraphQlPackage();
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
}
|
|
1858
|
+
if (cmd === 'init') {
|
|
1859
|
+
return init();
|
|
1860
|
+
}
|
|
1861
|
+
const context = await createContext();
|
|
1862
|
+
try {
|
|
1863
|
+
return await generate(context);
|
|
1864
|
+
}
|
|
1865
|
+
catch (error) {
|
|
1866
|
+
await lifecycleHooks(context.getConfig().hooks).onError(error.toString());
|
|
1867
|
+
throw error;
|
|
1871
1868
|
}
|
|
1872
1869
|
}
|
|
1873
1870
|
async function ensureGraphQlPackage() {
|
package/index.js
CHANGED
|
@@ -612,7 +612,7 @@ function buildOptions() {
|
|
|
612
612
|
};
|
|
613
613
|
}
|
|
614
614
|
function parseArgv(argv = process.argv) {
|
|
615
|
-
return yargs
|
|
615
|
+
return yargs.options(buildOptions()).parse(argv);
|
|
616
616
|
}
|
|
617
617
|
async function createContext(cliFlags = parseArgv(process.argv)) {
|
|
618
618
|
if (cliFlags.require && cliFlags.require.length > 0) {
|
|
@@ -750,9 +750,6 @@ function addHashToDocumentFiles(documentFilesPromise) {
|
|
|
750
750
|
}));
|
|
751
751
|
}
|
|
752
752
|
|
|
753
|
-
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
754
|
-
const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
755
|
-
|
|
756
753
|
function isListrError(err) {
|
|
757
754
|
return err.name === 'ListrError' && Array.isArray(err.errors) && err.errors.length > 0;
|
|
758
755
|
}
|
|
@@ -769,12 +766,9 @@ function cliError(err, exitOnError = true) {
|
|
|
769
766
|
}
|
|
770
767
|
// eslint-disable-next-line no-console
|
|
771
768
|
console.error(msg);
|
|
772
|
-
if (exitOnError
|
|
769
|
+
if (exitOnError) {
|
|
773
770
|
process.exit(1);
|
|
774
771
|
}
|
|
775
|
-
else if (exitOnError && isBrowser) {
|
|
776
|
-
throw err;
|
|
777
|
-
}
|
|
778
772
|
}
|
|
779
773
|
|
|
780
774
|
const makeDefaultLoader = (from) => {
|
|
@@ -934,7 +928,7 @@ async function executeCodegen(input) {
|
|
|
934
928
|
let outputSchemaAst;
|
|
935
929
|
let outputSchema;
|
|
936
930
|
const outputFileTemplateConfig = outputConfig.config || {};
|
|
937
|
-
|
|
931
|
+
let outputDocuments = [];
|
|
938
932
|
const outputSpecificSchemas = pluginHelpers.normalizeInstanceOrArray(outputConfig.schema);
|
|
939
933
|
const outputSpecificDocuments = pluginHelpers.normalizeInstanceOrArray(outputConfig.documents);
|
|
940
934
|
return new Listr([
|
|
@@ -970,20 +964,24 @@ async function executeCodegen(input) {
|
|
|
970
964
|
task: wrapTask(async () => {
|
|
971
965
|
debugLog(`[CLI] Loading Documents`);
|
|
972
966
|
// get different cache for shared docs and output specific docs
|
|
973
|
-
const
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
const documents = [];
|
|
983
|
-
results.forEach(source => documents.push(...source.documents));
|
|
984
|
-
if (documents.length > 0) {
|
|
985
|
-
outputDocuments.push(...documents);
|
|
967
|
+
const documentPointerMap = {};
|
|
968
|
+
const allDocumentsUnnormalizedPointers = [...rootDocuments, ...outputSpecificDocuments];
|
|
969
|
+
for (const unnormalizedPtr of allDocumentsUnnormalizedPointers) {
|
|
970
|
+
if (typeof unnormalizedPtr === 'string') {
|
|
971
|
+
documentPointerMap[unnormalizedPtr] = {};
|
|
972
|
+
}
|
|
973
|
+
else if (typeof unnormalizedPtr === 'object') {
|
|
974
|
+
Object.assign(documentPointerMap, unnormalizedPtr);
|
|
975
|
+
}
|
|
986
976
|
}
|
|
977
|
+
const hash = JSON.stringify(documentPointerMap);
|
|
978
|
+
const result = await cache('documents', hash, async () => {
|
|
979
|
+
const documents = await context.loadDocuments(documentPointerMap);
|
|
980
|
+
return {
|
|
981
|
+
documents,
|
|
982
|
+
};
|
|
983
|
+
});
|
|
984
|
+
outputDocuments = await result.documents;
|
|
987
985
|
}, filename, `Load GraphQL documents: ${filename}`),
|
|
988
986
|
},
|
|
989
987
|
{
|
|
@@ -1858,17 +1856,16 @@ function addIntrospection(config) {
|
|
|
1858
1856
|
|
|
1859
1857
|
async function runCli(cmd) {
|
|
1860
1858
|
await ensureGraphQlPackage();
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
}
|
|
1859
|
+
if (cmd === 'init') {
|
|
1860
|
+
return init();
|
|
1861
|
+
}
|
|
1862
|
+
const context = await createContext();
|
|
1863
|
+
try {
|
|
1864
|
+
return await generate(context);
|
|
1865
|
+
}
|
|
1866
|
+
catch (error) {
|
|
1867
|
+
await lifecycleHooks(context.getConfig().hooks).onError(error.toString());
|
|
1868
|
+
throw error;
|
|
1872
1869
|
}
|
|
1873
1870
|
}
|
|
1874
1871
|
async function ensureGraphQlPackage() {
|
package/index.mjs
CHANGED
|
@@ -585,7 +585,7 @@ function buildOptions() {
|
|
|
585
585
|
};
|
|
586
586
|
}
|
|
587
587
|
function parseArgv(argv = process.argv) {
|
|
588
|
-
return yargs
|
|
588
|
+
return yargs.options(buildOptions()).parse(argv);
|
|
589
589
|
}
|
|
590
590
|
async function createContext(cliFlags = parseArgv(process.argv)) {
|
|
591
591
|
if (cliFlags.require && cliFlags.require.length > 0) {
|
|
@@ -723,9 +723,6 @@ function addHashToDocumentFiles(documentFilesPromise) {
|
|
|
723
723
|
}));
|
|
724
724
|
}
|
|
725
725
|
|
|
726
|
-
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
727
|
-
const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
728
|
-
|
|
729
726
|
function isListrError(err) {
|
|
730
727
|
return err.name === 'ListrError' && Array.isArray(err.errors) && err.errors.length > 0;
|
|
731
728
|
}
|
|
@@ -742,12 +739,9 @@ function cliError(err, exitOnError = true) {
|
|
|
742
739
|
}
|
|
743
740
|
// eslint-disable-next-line no-console
|
|
744
741
|
console.error(msg);
|
|
745
|
-
if (exitOnError
|
|
742
|
+
if (exitOnError) {
|
|
746
743
|
process.exit(1);
|
|
747
744
|
}
|
|
748
|
-
else if (exitOnError && isBrowser) {
|
|
749
|
-
throw err;
|
|
750
|
-
}
|
|
751
745
|
}
|
|
752
746
|
|
|
753
747
|
const makeDefaultLoader = (from) => {
|
|
@@ -907,7 +901,7 @@ async function executeCodegen(input) {
|
|
|
907
901
|
let outputSchemaAst;
|
|
908
902
|
let outputSchema;
|
|
909
903
|
const outputFileTemplateConfig = outputConfig.config || {};
|
|
910
|
-
|
|
904
|
+
let outputDocuments = [];
|
|
911
905
|
const outputSpecificSchemas = normalizeInstanceOrArray(outputConfig.schema);
|
|
912
906
|
const outputSpecificDocuments = normalizeInstanceOrArray(outputConfig.documents);
|
|
913
907
|
return new Listr([
|
|
@@ -943,20 +937,24 @@ async function executeCodegen(input) {
|
|
|
943
937
|
task: wrapTask(async () => {
|
|
944
938
|
debugLog(`[CLI] Loading Documents`);
|
|
945
939
|
// get different cache for shared docs and output specific docs
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
const documents = [];
|
|
956
|
-
results.forEach(source => documents.push(...source.documents));
|
|
957
|
-
if (documents.length > 0) {
|
|
958
|
-
outputDocuments.push(...documents);
|
|
940
|
+
const documentPointerMap = {};
|
|
941
|
+
const allDocumentsUnnormalizedPointers = [...rootDocuments, ...outputSpecificDocuments];
|
|
942
|
+
for (const unnormalizedPtr of allDocumentsUnnormalizedPointers) {
|
|
943
|
+
if (typeof unnormalizedPtr === 'string') {
|
|
944
|
+
documentPointerMap[unnormalizedPtr] = {};
|
|
945
|
+
}
|
|
946
|
+
else if (typeof unnormalizedPtr === 'object') {
|
|
947
|
+
Object.assign(documentPointerMap, unnormalizedPtr);
|
|
948
|
+
}
|
|
959
949
|
}
|
|
950
|
+
const hash = JSON.stringify(documentPointerMap);
|
|
951
|
+
const result = await cache('documents', hash, async () => {
|
|
952
|
+
const documents = await context.loadDocuments(documentPointerMap);
|
|
953
|
+
return {
|
|
954
|
+
documents,
|
|
955
|
+
};
|
|
956
|
+
});
|
|
957
|
+
outputDocuments = await result.documents;
|
|
960
958
|
}, filename, `Load GraphQL documents: ${filename}`),
|
|
961
959
|
},
|
|
962
960
|
{
|
|
@@ -1831,17 +1829,16 @@ function addIntrospection(config) {
|
|
|
1831
1829
|
|
|
1832
1830
|
async function runCli(cmd) {
|
|
1833
1831
|
await ensureGraphQlPackage();
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
}
|
|
1832
|
+
if (cmd === 'init') {
|
|
1833
|
+
return init();
|
|
1834
|
+
}
|
|
1835
|
+
const context = await createContext();
|
|
1836
|
+
try {
|
|
1837
|
+
return await generate(context);
|
|
1838
|
+
}
|
|
1839
|
+
catch (error) {
|
|
1840
|
+
await lifecycleHooks(context.getConfig().hooks).onError(error.toString());
|
|
1841
|
+
throw error;
|
|
1845
1842
|
}
|
|
1846
1843
|
}
|
|
1847
1844
|
async function ensureGraphQlPackage() {
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "2.7.0
|
|
3
|
+
"version": "2.7.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
8
|
"@graphql-codegen/core": "2.5.1",
|
|
9
9
|
"@graphql-codegen/plugin-helpers": "^2.4.1",
|
|
10
|
-
"@graphql-tools/apollo-engine-loader": "^7.
|
|
11
|
-
"@graphql-tools/code-file-loader": "^7.
|
|
10
|
+
"@graphql-tools/apollo-engine-loader": "^7.3.1",
|
|
11
|
+
"@graphql-tools/code-file-loader": "^7.0.6",
|
|
12
12
|
"@graphql-tools/git-loader": "^7.0.5",
|
|
13
13
|
"@graphql-tools/github-loader": "^7.0.5",
|
|
14
14
|
"@graphql-tools/graphql-file-loader": "^7.0.5",
|
|
15
15
|
"@graphql-tools/json-file-loader": "^7.1.2",
|
|
16
16
|
"@graphql-tools/load": "^7.3.0",
|
|
17
|
-
"@graphql-tools/prisma-loader": "^7.
|
|
18
|
-
"@graphql-tools/url-loader": "^7.
|
|
17
|
+
"@graphql-tools/prisma-loader": "^7.2.2",
|
|
18
|
+
"@graphql-tools/url-loader": "^7.12.1",
|
|
19
19
|
"@graphql-tools/utils": "^8.1.1",
|
|
20
20
|
"ansi-escapes": "^4.3.1",
|
|
21
21
|
"chalk": "^4.1.0",
|
|
@@ -24,11 +24,8 @@
|
|
|
24
24
|
"common-tags": "^1.8.0",
|
|
25
25
|
"cosmiconfig": "^7.0.0",
|
|
26
26
|
"debounce": "^1.2.0",
|
|
27
|
-
"dependency-graph": "^0.11.0",
|
|
28
27
|
"detect-indent": "^6.0.0",
|
|
29
|
-
"
|
|
30
|
-
"globby": "^11.0.4",
|
|
31
|
-
"graphql-config": "^4.3.1",
|
|
28
|
+
"graphql-config": "^4.1.0",
|
|
32
29
|
"inquirer": "^8.0.0",
|
|
33
30
|
"is-glob": "^4.0.1",
|
|
34
31
|
"json-to-pretty-yaml": "^1.2.2",
|
|
@@ -36,12 +33,9 @@
|
|
|
36
33
|
"listr": "^0.14.3",
|
|
37
34
|
"listr-update-renderer": "^0.5.0",
|
|
38
35
|
"log-symbols": "^4.0.0",
|
|
39
|
-
"minimatch": "^5.0.0",
|
|
40
36
|
"mkdirp": "^1.0.4",
|
|
41
37
|
"string-env-interpolation": "^1.0.1",
|
|
42
38
|
"ts-log": "^2.2.3",
|
|
43
|
-
"tslib": "~2.4.0",
|
|
44
|
-
"valid-url": "^1.0.9",
|
|
45
39
|
"wrap-ansi": "^7.0.0",
|
|
46
40
|
"yaml": "^1.10.0",
|
|
47
41
|
"yargs": "^17.0.0"
|
|
@@ -91,7 +85,6 @@
|
|
|
91
85
|
"bin": {
|
|
92
86
|
"gql-gen": "bin.js",
|
|
93
87
|
"graphql-codegen": "bin.js",
|
|
94
|
-
"graphql-code-generator": "bin.js"
|
|
95
|
-
"graphql-codegen-esm": "bin.mjs"
|
|
88
|
+
"graphql-code-generator": "bin.js"
|
|
96
89
|
}
|
|
97
90
|
}
|