@graphql-codegen/cli 2.7.0-alpha-8791d9688.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 +28 -25
- package/index.js +28 -25
- package/index.mjs +28 -25
- package/package.json +4 -4
- package/utils/try-to-build-schema.d.ts +0 -2
package/bin.js
CHANGED
|
@@ -1008,7 +1008,7 @@ async function executeCodegen(input) {
|
|
|
1008
1008
|
let outputSchemaAst;
|
|
1009
1009
|
let outputSchema;
|
|
1010
1010
|
const outputFileTemplateConfig = outputConfig.config || {};
|
|
1011
|
-
|
|
1011
|
+
let outputDocuments = [];
|
|
1012
1012
|
const outputSpecificSchemas = pluginHelpers.normalizeInstanceOrArray(outputConfig.schema);
|
|
1013
1013
|
const outputSpecificDocuments = pluginHelpers.normalizeInstanceOrArray(outputConfig.documents);
|
|
1014
1014
|
return new Listr([
|
|
@@ -1044,20 +1044,24 @@ async function executeCodegen(input) {
|
|
|
1044
1044
|
task: wrapTask(async () => {
|
|
1045
1045
|
debugLog(`[CLI] Loading Documents`);
|
|
1046
1046
|
// get different cache for shared docs and output specific docs
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
const documents = [];
|
|
1057
|
-
results.forEach(source => documents.push(...source.documents));
|
|
1058
|
-
if (documents.length > 0) {
|
|
1059
|
-
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
|
+
}
|
|
1060
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;
|
|
1061
1065
|
}, filename, `Load GraphQL documents: ${filename}`),
|
|
1062
1066
|
},
|
|
1063
1067
|
{
|
|
@@ -1851,17 +1855,16 @@ function addIntrospection(config) {
|
|
|
1851
1855
|
|
|
1852
1856
|
async function runCli(cmd) {
|
|
1853
1857
|
await ensureGraphQlPackage();
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
}
|
|
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;
|
|
1865
1868
|
}
|
|
1866
1869
|
}
|
|
1867
1870
|
async function ensureGraphQlPackage() {
|
package/index.js
CHANGED
|
@@ -928,7 +928,7 @@ async function executeCodegen(input) {
|
|
|
928
928
|
let outputSchemaAst;
|
|
929
929
|
let outputSchema;
|
|
930
930
|
const outputFileTemplateConfig = outputConfig.config || {};
|
|
931
|
-
|
|
931
|
+
let outputDocuments = [];
|
|
932
932
|
const outputSpecificSchemas = pluginHelpers.normalizeInstanceOrArray(outputConfig.schema);
|
|
933
933
|
const outputSpecificDocuments = pluginHelpers.normalizeInstanceOrArray(outputConfig.documents);
|
|
934
934
|
return new Listr([
|
|
@@ -964,20 +964,24 @@ async function executeCodegen(input) {
|
|
|
964
964
|
task: wrapTask(async () => {
|
|
965
965
|
debugLog(`[CLI] Loading Documents`);
|
|
966
966
|
// get different cache for shared docs and output specific docs
|
|
967
|
-
const
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
const documents = [];
|
|
977
|
-
results.forEach(source => documents.push(...source.documents));
|
|
978
|
-
if (documents.length > 0) {
|
|
979
|
-
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
|
+
}
|
|
980
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;
|
|
981
985
|
}, filename, `Load GraphQL documents: ${filename}`),
|
|
982
986
|
},
|
|
983
987
|
{
|
|
@@ -1852,17 +1856,16 @@ function addIntrospection(config) {
|
|
|
1852
1856
|
|
|
1853
1857
|
async function runCli(cmd) {
|
|
1854
1858
|
await ensureGraphQlPackage();
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
}
|
|
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;
|
|
1866
1869
|
}
|
|
1867
1870
|
}
|
|
1868
1871
|
async function ensureGraphQlPackage() {
|
package/index.mjs
CHANGED
|
@@ -901,7 +901,7 @@ async function executeCodegen(input) {
|
|
|
901
901
|
let outputSchemaAst;
|
|
902
902
|
let outputSchema;
|
|
903
903
|
const outputFileTemplateConfig = outputConfig.config || {};
|
|
904
|
-
|
|
904
|
+
let outputDocuments = [];
|
|
905
905
|
const outputSpecificSchemas = normalizeInstanceOrArray(outputConfig.schema);
|
|
906
906
|
const outputSpecificDocuments = normalizeInstanceOrArray(outputConfig.documents);
|
|
907
907
|
return new Listr([
|
|
@@ -937,20 +937,24 @@ async function executeCodegen(input) {
|
|
|
937
937
|
task: wrapTask(async () => {
|
|
938
938
|
debugLog(`[CLI] Loading Documents`);
|
|
939
939
|
// get different cache for shared docs and output specific docs
|
|
940
|
-
const
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
const documents = [];
|
|
950
|
-
results.forEach(source => documents.push(...source.documents));
|
|
951
|
-
if (documents.length > 0) {
|
|
952
|
-
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
|
+
}
|
|
953
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;
|
|
954
958
|
}, filename, `Load GraphQL documents: ${filename}`),
|
|
955
959
|
},
|
|
956
960
|
{
|
|
@@ -1825,17 +1829,16 @@ function addIntrospection(config) {
|
|
|
1825
1829
|
|
|
1826
1830
|
async function runCli(cmd) {
|
|
1827
1831
|
await ensureGraphQlPackage();
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
}
|
|
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;
|
|
1839
1842
|
}
|
|
1840
1843
|
}
|
|
1841
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.
|
|
10
|
+
"@graphql-tools/apollo-engine-loader": "^7.3.1",
|
|
11
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",
|