@graphql-codegen/cli 2.12.2 → 2.12.3-alpha-20220927092513-40482d1aa
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/cjs/init/helpers.js +34 -3
- package/cjs/init/index.js +4 -3
- package/cjs/init/plugins.js +6 -42
- package/cjs/init/questions.js +52 -12
- package/cjs/init/targets.js +5 -1
- package/cjs/init/types.js +2 -1
- package/esm/init/helpers.js +34 -3
- package/esm/init/index.js +4 -3
- package/esm/init/plugins.js +6 -42
- package/esm/init/questions.js +50 -11
- package/esm/init/targets.js +5 -1
- package/esm/init/types.js +2 -1
- package/package.json +8 -4
- package/typings/init/questions.d.cts +2 -1
- package/typings/init/questions.d.ts +2 -1
- package/typings/init/types.d.cts +4 -3
- package/typings/init/types.d.ts +4 -3
package/cjs/init/helpers.js
CHANGED
|
@@ -7,13 +7,44 @@ const path_1 = require("path");
|
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const detect_indent_1 = tslib_1.__importDefault(require("detect-indent"));
|
|
9
9
|
const get_latest_version_js_1 = require("../utils/get-latest-version.js");
|
|
10
|
+
const template_1 = tslib_1.__importDefault(require("@babel/template"));
|
|
11
|
+
const generator_1 = tslib_1.__importDefault(require("@babel/generator"));
|
|
12
|
+
const t = tslib_1.__importStar(require("@babel/types"));
|
|
13
|
+
function jsObjectToBabelObjectExpression(obj) {
|
|
14
|
+
const objExp = t.objectExpression([]);
|
|
15
|
+
Object.entries(obj).forEach(([key, val]) => {
|
|
16
|
+
if (Array.isArray(val)) {
|
|
17
|
+
objExp.properties.push(t.objectProperty(/^[a-zA-Z0-9]+$/.test(key) ? t.identifier(key) : t.stringLiteral(key), t.arrayExpression(val.map(v => (typeof v === 'object' ? jsObjectToBabelObjectExpression(v) : t.valueToNode(v))))));
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
objExp.properties.push(t.objectProperty(/^[a-zA-Z0-9]+$/.test(key) ? t.identifier(key) : t.stringLiteral(key), typeof val === 'object' ? jsObjectToBabelObjectExpression(val) : t.valueToNode(val)));
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return objExp;
|
|
24
|
+
}
|
|
10
25
|
// Parses config and writes it to a file
|
|
11
26
|
async function writeConfig(answers, config) {
|
|
12
27
|
const YAML = await Promise.resolve().then(() => tslib_1.__importStar(require('json-to-pretty-yaml'))).then(m => ('default' in m ? m.default : m));
|
|
13
|
-
const ext = answers.config.toLocaleLowerCase().
|
|
14
|
-
const content = ext === 'json' ? JSON.stringify(config) : YAML.stringify(config);
|
|
28
|
+
const ext = answers.config.toLocaleLowerCase().split('.')[1];
|
|
15
29
|
const fullPath = (0, path_1.resolve)(process.cwd(), answers.config);
|
|
16
30
|
const relativePath = (0, path_1.relative)(process.cwd(), answers.config);
|
|
31
|
+
let content;
|
|
32
|
+
if (ext === 'ts') {
|
|
33
|
+
const buildRequire = template_1.default.statement(`%%config%%`);
|
|
34
|
+
const ast = buildRequire({
|
|
35
|
+
config: jsObjectToBabelObjectExpression(config),
|
|
36
|
+
});
|
|
37
|
+
content = `
|
|
38
|
+
import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
39
|
+
|
|
40
|
+
const config: CodegenConfig = ${(0, generator_1.default)(ast).code.replace(/\(|\)/g, '')}
|
|
41
|
+
|
|
42
|
+
export default config;
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
content = ext === 'json' ? JSON.stringify(config) : YAML.stringify(config);
|
|
47
|
+
}
|
|
17
48
|
(0, fs_1.writeFileSync)(fullPath, content, {
|
|
18
49
|
encoding: 'utf-8',
|
|
19
50
|
});
|
|
@@ -40,7 +71,7 @@ async function writePackage(answers, configLocation) {
|
|
|
40
71
|
if (!pkg.devDependencies) {
|
|
41
72
|
pkg.devDependencies = {};
|
|
42
73
|
}
|
|
43
|
-
await Promise.all(answers.plugins.map(async (plugin) => {
|
|
74
|
+
await Promise.all((answers.plugins || []).map(async (plugin) => {
|
|
44
75
|
pkg.devDependencies[plugin.package] = await (0, get_latest_version_js_1.getLatestVersion)(plugin.package);
|
|
45
76
|
}));
|
|
46
77
|
if (answers.introspection) {
|
package/cjs/init/index.js
CHANGED
|
@@ -22,10 +22,11 @@ async function init() {
|
|
|
22
22
|
const config = {
|
|
23
23
|
overwrite: true,
|
|
24
24
|
schema: answers.schema,
|
|
25
|
-
documents: answers.targets.includes(types_js_1.Tags.
|
|
25
|
+
documents: answers.targets.includes(types_js_1.Tags.client) ? answers.documents : undefined,
|
|
26
26
|
generates: {
|
|
27
27
|
[answers.output]: {
|
|
28
|
-
|
|
28
|
+
preset: answers.targets.includes(types_js_1.Tags.client) ? 'client' : undefined,
|
|
29
|
+
plugins: answers.plugins ? answers.plugins.map(p => p.value) : [],
|
|
29
30
|
},
|
|
30
31
|
},
|
|
31
32
|
};
|
|
@@ -41,7 +42,7 @@ async function init() {
|
|
|
41
42
|
// Emit status to the terminal
|
|
42
43
|
log(`
|
|
43
44
|
Config file generated at ${(0, helpers_js_1.bold)(relativePath)}
|
|
44
|
-
|
|
45
|
+
|
|
45
46
|
${(0, helpers_js_1.bold)('$ npm install')}
|
|
46
47
|
|
|
47
48
|
To install the plugins.
|
package/cjs/init/plugins.js
CHANGED
|
@@ -18,7 +18,7 @@ exports.plugins = [
|
|
|
18
18
|
package: '@graphql-codegen/typescript-operations',
|
|
19
19
|
value: 'typescript-operations',
|
|
20
20
|
pathInRepo: 'typescript/operations',
|
|
21
|
-
available: tags => allOf(tags, types_js_1.Tags.
|
|
21
|
+
available: tags => allOf(tags, types_js_1.Tags.client, types_js_1.Tags.typescript) || hasTag(types_js_1.Tags.stencil)(tags),
|
|
22
22
|
shouldBeSelected: tags => oneOf(tags, types_js_1.Tags.angular, types_js_1.Tags.stencil) || allOf(tags, types_js_1.Tags.typescript, types_js_1.Tags.react),
|
|
23
23
|
defaultExtension: '.ts',
|
|
24
24
|
},
|
|
@@ -45,7 +45,7 @@ exports.plugins = [
|
|
|
45
45
|
package: '@graphql-codegen/flow-operations',
|
|
46
46
|
value: 'flow-operations',
|
|
47
47
|
pathInRepo: 'flow/operations',
|
|
48
|
-
available: tags => allOf(tags, types_js_1.Tags.
|
|
48
|
+
available: tags => allOf(tags, types_js_1.Tags.client, types_js_1.Tags.flow),
|
|
49
49
|
shouldBeSelected: tags => noneOf(tags, types_js_1.Tags.typescript),
|
|
50
50
|
defaultExtension: '.js',
|
|
51
51
|
},
|
|
@@ -58,42 +58,6 @@ exports.plugins = [
|
|
|
58
58
|
shouldBeSelected: tags => noneOf(tags, types_js_1.Tags.typescript),
|
|
59
59
|
defaultExtension: '.js',
|
|
60
60
|
},
|
|
61
|
-
{
|
|
62
|
-
name: `TypeScript Apollo Angular ${(0, helpers_js_1.italic)('(typed GQL services)')}`,
|
|
63
|
-
package: '@graphql-codegen/typescript-apollo-angular',
|
|
64
|
-
value: 'typescript-apollo-angular',
|
|
65
|
-
pathInRepo: 'typescript/apollo-angular',
|
|
66
|
-
available: hasTag(types_js_1.Tags.angular),
|
|
67
|
-
shouldBeSelected: () => true,
|
|
68
|
-
defaultExtension: '.js',
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
name: `TypeScript Vue Apollo Composition API ${(0, helpers_js_1.italic)('(typed functions)')}`,
|
|
72
|
-
package: '@graphql-codegen/typescript-vue-apollo',
|
|
73
|
-
value: 'typescript-vue-apollo',
|
|
74
|
-
pathInRepo: 'typescript/vue-apollo',
|
|
75
|
-
available: tags => allOf(tags, types_js_1.Tags.vue, types_js_1.Tags.typescript),
|
|
76
|
-
shouldBeSelected: () => true,
|
|
77
|
-
defaultExtension: '.ts',
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
name: `TypeScript Vue Apollo Smart Operations ${(0, helpers_js_1.italic)('(typed functions)')}`,
|
|
81
|
-
package: '@graphql-codegen/typescript-vue-apollo-smart-ops',
|
|
82
|
-
value: 'typescript-vue-apollo-smart-ops',
|
|
83
|
-
pathInRepo: 'typescript/vue-apollo-smart-ops',
|
|
84
|
-
available: tags => allOf(tags, types_js_1.Tags.vue, types_js_1.Tags.typescript),
|
|
85
|
-
shouldBeSelected: () => true,
|
|
86
|
-
defaultExtension: '.ts',
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: `TypeScript React Apollo ${(0, helpers_js_1.italic)('(typed components and HOCs)')}`,
|
|
90
|
-
package: '@graphql-codegen/typescript-react-apollo',
|
|
91
|
-
value: 'typescript-react-apollo',
|
|
92
|
-
pathInRepo: 'typescript/react-apollo',
|
|
93
|
-
available: tags => allOf(tags, types_js_1.Tags.react, types_js_1.Tags.typescript),
|
|
94
|
-
shouldBeSelected: () => true,
|
|
95
|
-
defaultExtension: '.tsx',
|
|
96
|
-
},
|
|
97
61
|
{
|
|
98
62
|
name: `TypeScript Stencil Apollo ${(0, helpers_js_1.italic)('(typed components)')}`,
|
|
99
63
|
package: '@graphql-codegen/typescript-stencil-apollo',
|
|
@@ -117,7 +81,7 @@ exports.plugins = [
|
|
|
117
81
|
package: '@graphql-codegen/typescript-graphql-files-modules',
|
|
118
82
|
value: 'typescript-graphql-files-modules',
|
|
119
83
|
pathInRepo: 'typescript/graphql-files-modules',
|
|
120
|
-
available: tags => allOf(tags, types_js_1.Tags.
|
|
84
|
+
available: tags => allOf(tags, types_js_1.Tags.client, types_js_1.Tags.typescript) || hasTag(types_js_1.Tags.stencil)(tags),
|
|
121
85
|
shouldBeSelected: () => false,
|
|
122
86
|
defaultExtension: '.ts',
|
|
123
87
|
},
|
|
@@ -126,7 +90,7 @@ exports.plugins = [
|
|
|
126
90
|
package: '@graphql-codegen/typescript-document-nodes',
|
|
127
91
|
value: 'typescript-document-nodes',
|
|
128
92
|
pathInRepo: 'typescript/document-nodes',
|
|
129
|
-
available: tags => allOf(tags, types_js_1.Tags.typescript),
|
|
93
|
+
available: tags => allOf(tags, types_js_1.Tags.typescript) || hasTag(types_js_1.Tags.stencil)(tags),
|
|
130
94
|
shouldBeSelected: () => false,
|
|
131
95
|
defaultExtension: '.ts',
|
|
132
96
|
},
|
|
@@ -135,7 +99,7 @@ exports.plugins = [
|
|
|
135
99
|
package: '@graphql-codegen/fragment-matcher',
|
|
136
100
|
value: 'fragment-matcher',
|
|
137
101
|
pathInRepo: 'other/fragment-matcher',
|
|
138
|
-
available: hasTag(types_js_1.Tags.
|
|
102
|
+
available: tags => hasTag(types_js_1.Tags.client)(tags) || hasTag(types_js_1.Tags.stencil)(tags),
|
|
139
103
|
shouldBeSelected: () => false,
|
|
140
104
|
defaultExtension: '.ts',
|
|
141
105
|
},
|
|
@@ -144,7 +108,7 @@ exports.plugins = [
|
|
|
144
108
|
package: '@graphql-codegen/urql-introspection',
|
|
145
109
|
value: 'urql-introspection',
|
|
146
110
|
pathInRepo: 'other/urql-introspection',
|
|
147
|
-
available: hasTag(types_js_1.Tags.
|
|
111
|
+
available: tags => hasTag(types_js_1.Tags.client)(tags) || hasTag(types_js_1.Tags.stencil)(tags),
|
|
148
112
|
shouldBeSelected: () => false,
|
|
149
113
|
defaultExtension: '.ts',
|
|
150
114
|
},
|
package/cjs/init/questions.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOutputDefaultValue = exports.getPluginChoices = exports.getApplicationTypeChoices = exports.getQuestions = void 0;
|
|
3
|
+
exports.getDocumentsDefaultValue = exports.getOutputDefaultValue = exports.getPluginChoices = exports.getApplicationTypeChoices = exports.getQuestions = void 0;
|
|
4
4
|
const helpers_js_1 = require("./helpers.js");
|
|
5
5
|
const types_js_1 = require("./types.js");
|
|
6
6
|
const plugins_js_1 = require("./plugins.js");
|
|
7
7
|
function getQuestions(possibleTargets) {
|
|
8
8
|
return [
|
|
9
9
|
{
|
|
10
|
-
type: '
|
|
10
|
+
type: 'list',
|
|
11
11
|
name: 'targets',
|
|
12
12
|
message: `What type of application are you building?`,
|
|
13
13
|
choices: getApplicationTypeChoices(possibleTargets),
|
|
14
14
|
validate: ((targets) => targets.length > 0),
|
|
15
|
+
default: getApplicationTypeChoices(possibleTargets).findIndex(c => c.checked),
|
|
15
16
|
},
|
|
16
17
|
{
|
|
17
18
|
type: 'input',
|
|
@@ -29,14 +30,20 @@ function getQuestions(possibleTargets) {
|
|
|
29
30
|
// flatten targets
|
|
30
31
|
// I can't find an API in Inquirer that would do that
|
|
31
32
|
answers.targets = normalizeTargets(answers.targets);
|
|
32
|
-
return answers.targets.includes(types_js_1.Tags.
|
|
33
|
+
return answers.targets.includes(types_js_1.Tags.client) || answers.targets.includes(types_js_1.Tags.stencil);
|
|
33
34
|
},
|
|
34
|
-
default:
|
|
35
|
+
default: getDocumentsDefaultValue,
|
|
35
36
|
validate: (str) => str.length > 0,
|
|
36
37
|
},
|
|
37
38
|
{
|
|
38
39
|
type: 'checkbox',
|
|
39
40
|
name: 'plugins',
|
|
41
|
+
when: answers => {
|
|
42
|
+
// flatten targets
|
|
43
|
+
// I can't find an API in Inquirer that would do that
|
|
44
|
+
answers.targets = normalizeTargets(answers.targets);
|
|
45
|
+
return !answers.targets.includes(types_js_1.Tags.client);
|
|
46
|
+
},
|
|
40
47
|
message: 'Pick plugins:',
|
|
41
48
|
choices: getPluginChoices,
|
|
42
49
|
validate: ((plugins) => plugins.length > 0),
|
|
@@ -51,22 +58,24 @@ function getQuestions(possibleTargets) {
|
|
|
51
58
|
{
|
|
52
59
|
type: 'confirm',
|
|
53
60
|
name: 'introspection',
|
|
61
|
+
default: false,
|
|
54
62
|
message: 'Do you want to generate an introspection file?',
|
|
55
63
|
},
|
|
56
64
|
{
|
|
57
65
|
type: 'input',
|
|
58
66
|
name: 'config',
|
|
59
67
|
message: 'How to name the config file?',
|
|
60
|
-
default: 'codegen.yml',
|
|
68
|
+
default: answers => (answers.targets.includes(types_js_1.Tags.client) ? 'codegen.ts' : 'codegen.yml'),
|
|
61
69
|
validate: (str) => {
|
|
62
70
|
const isNotEmpty = str.length > 0;
|
|
63
|
-
const hasCorrectExtension = ['json', 'yml', 'yaml'].some(ext => str.toLocaleLowerCase().endsWith(`.${ext}`));
|
|
71
|
+
const hasCorrectExtension = ['json', 'yml', 'yaml', 'js', 'ts'].some(ext => str.toLocaleLowerCase().endsWith(`.${ext}`));
|
|
64
72
|
return isNotEmpty && hasCorrectExtension;
|
|
65
73
|
},
|
|
66
74
|
},
|
|
67
75
|
{
|
|
68
76
|
type: 'input',
|
|
69
77
|
name: 'script',
|
|
78
|
+
default: 'codegen',
|
|
70
79
|
message: 'What script in package.json should run the codegen?',
|
|
71
80
|
validate: (str) => str.length > 0,
|
|
72
81
|
},
|
|
@@ -81,8 +90,9 @@ function getApplicationTypeChoices(possibleTargets) {
|
|
|
81
90
|
else if (possibleTargets.Flow) {
|
|
82
91
|
tags.push(types_js_1.Tags.flow);
|
|
83
92
|
}
|
|
84
|
-
else {
|
|
85
|
-
tags.push(types_js_1.Tags.
|
|
93
|
+
else if (possibleTargets.Node) {
|
|
94
|
+
tags.push(types_js_1.Tags.typescript);
|
|
95
|
+
tags.push(types_js_1.Tags.flow);
|
|
86
96
|
}
|
|
87
97
|
return tags;
|
|
88
98
|
}
|
|
@@ -96,25 +106,37 @@ function getApplicationTypeChoices(possibleTargets) {
|
|
|
96
106
|
{
|
|
97
107
|
name: 'Application built with Angular',
|
|
98
108
|
key: 'angular',
|
|
99
|
-
value: [types_js_1.Tags.angular, types_js_1.Tags.
|
|
109
|
+
value: [types_js_1.Tags.angular, types_js_1.Tags.client],
|
|
100
110
|
checked: possibleTargets.Angular,
|
|
101
111
|
},
|
|
102
112
|
{
|
|
103
113
|
name: 'Application built with React',
|
|
104
114
|
key: 'react',
|
|
105
|
-
value: withFlowOrTypescript([types_js_1.Tags.react, types_js_1.Tags.
|
|
115
|
+
value: withFlowOrTypescript([types_js_1.Tags.react, types_js_1.Tags.client]),
|
|
106
116
|
checked: possibleTargets.React,
|
|
107
117
|
},
|
|
108
118
|
{
|
|
109
119
|
name: 'Application built with Stencil',
|
|
110
120
|
key: 'stencil',
|
|
111
|
-
value: [types_js_1.Tags.stencil, types_js_1.Tags.
|
|
121
|
+
value: [types_js_1.Tags.stencil, types_js_1.Tags.typescript],
|
|
112
122
|
checked: possibleTargets.Stencil,
|
|
113
123
|
},
|
|
124
|
+
{
|
|
125
|
+
name: 'Application built with Vue',
|
|
126
|
+
key: 'vue',
|
|
127
|
+
value: [types_js_1.Tags.vue, types_js_1.Tags.client],
|
|
128
|
+
checked: possibleTargets.Vue,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'Application using graphql-request',
|
|
132
|
+
key: 'graphqlRequest',
|
|
133
|
+
value: [types_js_1.Tags.graphqlRequest, types_js_1.Tags.client],
|
|
134
|
+
checked: possibleTargets.graphqlRequest,
|
|
135
|
+
},
|
|
114
136
|
{
|
|
115
137
|
name: 'Application built with other framework or vanilla JS',
|
|
116
138
|
key: 'client',
|
|
117
|
-
value: [types_js_1.Tags.
|
|
139
|
+
value: [types_js_1.Tags.typescript, types_js_1.Tags.flow],
|
|
118
140
|
checked: possibleTargets.Browser && !possibleTargets.Angular && !possibleTargets.React && !possibleTargets.Stencil,
|
|
119
141
|
},
|
|
120
142
|
];
|
|
@@ -136,6 +158,9 @@ function normalizeTargets(targets) {
|
|
|
136
158
|
return [].concat(...targets);
|
|
137
159
|
}
|
|
138
160
|
function getOutputDefaultValue(answers) {
|
|
161
|
+
if (answers.targets.includes(types_js_1.Tags.client)) {
|
|
162
|
+
return 'src/gql';
|
|
163
|
+
}
|
|
139
164
|
if (answers.plugins.some(plugin => plugin.defaultExtension === '.tsx')) {
|
|
140
165
|
return 'src/generated/graphql.tsx';
|
|
141
166
|
}
|
|
@@ -145,3 +170,18 @@ function getOutputDefaultValue(answers) {
|
|
|
145
170
|
return 'src/generated/graphql.js';
|
|
146
171
|
}
|
|
147
172
|
exports.getOutputDefaultValue = getOutputDefaultValue;
|
|
173
|
+
function getDocumentsDefaultValue(answers) {
|
|
174
|
+
if (answers.targets.includes(types_js_1.Tags.vue)) {
|
|
175
|
+
return 'src/**/*.vue';
|
|
176
|
+
}
|
|
177
|
+
else if (answers.targets.includes(types_js_1.Tags.angular)) {
|
|
178
|
+
return 'src/**/*.ts';
|
|
179
|
+
}
|
|
180
|
+
else if (answers.targets.includes(types_js_1.Tags.client)) {
|
|
181
|
+
return 'src/**/*.tsx';
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
return 'src/**/*.graphql';
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
exports.getDocumentsDefaultValue = getDocumentsDefaultValue;
|
package/cjs/init/targets.js
CHANGED
|
@@ -17,10 +17,11 @@ async function guessTargets() {
|
|
|
17
17
|
[types_js_1.Tags.react]: isReact(dependencies),
|
|
18
18
|
[types_js_1.Tags.stencil]: isStencil(dependencies),
|
|
19
19
|
[types_js_1.Tags.vue]: isVue(dependencies),
|
|
20
|
-
[types_js_1.Tags.
|
|
20
|
+
[types_js_1.Tags.client]: false,
|
|
21
21
|
[types_js_1.Tags.node]: false,
|
|
22
22
|
[types_js_1.Tags.typescript]: isTypescript(dependencies),
|
|
23
23
|
[types_js_1.Tags.flow]: isFlow(dependencies),
|
|
24
|
+
[types_js_1.Tags.graphqlRequest]: isGraphqlRequest(dependencies),
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
exports.guessTargets = guessTargets;
|
|
@@ -42,3 +43,6 @@ function isTypescript(dependencies) {
|
|
|
42
43
|
function isFlow(dependencies) {
|
|
43
44
|
return dependencies.includes('flow');
|
|
44
45
|
}
|
|
46
|
+
function isGraphqlRequest(dependencies) {
|
|
47
|
+
return dependencies.includes('graphql-request');
|
|
48
|
+
}
|
package/cjs/init/types.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Tags = void 0;
|
|
4
4
|
var Tags;
|
|
5
5
|
(function (Tags) {
|
|
6
|
-
Tags["
|
|
6
|
+
Tags["client"] = "Browser";
|
|
7
7
|
Tags["node"] = "Node";
|
|
8
8
|
Tags["typescript"] = "TypeScript";
|
|
9
9
|
Tags["flow"] = "Flow";
|
|
@@ -11,4 +11,5 @@ var Tags;
|
|
|
11
11
|
Tags["stencil"] = "Stencil";
|
|
12
12
|
Tags["react"] = "React";
|
|
13
13
|
Tags["vue"] = "Vue";
|
|
14
|
+
Tags["graphqlRequest"] = "graphqlRequest";
|
|
14
15
|
})(Tags = exports.Tags || (exports.Tags = {}));
|
package/esm/init/helpers.js
CHANGED
|
@@ -3,13 +3,44 @@ import { resolve, relative } from 'path';
|
|
|
3
3
|
import { writeFileSync, readFileSync } from 'fs';
|
|
4
4
|
import detectIndent from 'detect-indent';
|
|
5
5
|
import { getLatestVersion } from '../utils/get-latest-version.js';
|
|
6
|
+
import template from '@babel/template';
|
|
7
|
+
import generate from '@babel/generator';
|
|
8
|
+
import * as t from '@babel/types';
|
|
9
|
+
function jsObjectToBabelObjectExpression(obj) {
|
|
10
|
+
const objExp = t.objectExpression([]);
|
|
11
|
+
Object.entries(obj).forEach(([key, val]) => {
|
|
12
|
+
if (Array.isArray(val)) {
|
|
13
|
+
objExp.properties.push(t.objectProperty(/^[a-zA-Z0-9]+$/.test(key) ? t.identifier(key) : t.stringLiteral(key), t.arrayExpression(val.map(v => (typeof v === 'object' ? jsObjectToBabelObjectExpression(v) : t.valueToNode(v))))));
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
objExp.properties.push(t.objectProperty(/^[a-zA-Z0-9]+$/.test(key) ? t.identifier(key) : t.stringLiteral(key), typeof val === 'object' ? jsObjectToBabelObjectExpression(val) : t.valueToNode(val)));
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return objExp;
|
|
20
|
+
}
|
|
6
21
|
// Parses config and writes it to a file
|
|
7
22
|
export async function writeConfig(answers, config) {
|
|
8
23
|
const YAML = await import('json-to-pretty-yaml').then(m => ('default' in m ? m.default : m));
|
|
9
|
-
const ext = answers.config.toLocaleLowerCase().
|
|
10
|
-
const content = ext === 'json' ? JSON.stringify(config) : YAML.stringify(config);
|
|
24
|
+
const ext = answers.config.toLocaleLowerCase().split('.')[1];
|
|
11
25
|
const fullPath = resolve(process.cwd(), answers.config);
|
|
12
26
|
const relativePath = relative(process.cwd(), answers.config);
|
|
27
|
+
let content;
|
|
28
|
+
if (ext === 'ts') {
|
|
29
|
+
const buildRequire = template.statement(`%%config%%`);
|
|
30
|
+
const ast = buildRequire({
|
|
31
|
+
config: jsObjectToBabelObjectExpression(config),
|
|
32
|
+
});
|
|
33
|
+
content = `
|
|
34
|
+
import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
35
|
+
|
|
36
|
+
const config: CodegenConfig = ${generate(ast).code.replace(/\(|\)/g, '')}
|
|
37
|
+
|
|
38
|
+
export default config;
|
|
39
|
+
`;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
content = ext === 'json' ? JSON.stringify(config) : YAML.stringify(config);
|
|
43
|
+
}
|
|
13
44
|
writeFileSync(fullPath, content, {
|
|
14
45
|
encoding: 'utf-8',
|
|
15
46
|
});
|
|
@@ -35,7 +66,7 @@ export async function writePackage(answers, configLocation) {
|
|
|
35
66
|
if (!pkg.devDependencies) {
|
|
36
67
|
pkg.devDependencies = {};
|
|
37
68
|
}
|
|
38
|
-
await Promise.all(answers.plugins.map(async (plugin) => {
|
|
69
|
+
await Promise.all((answers.plugins || []).map(async (plugin) => {
|
|
39
70
|
pkg.devDependencies[plugin.package] = await getLatestVersion(plugin.package);
|
|
40
71
|
}));
|
|
41
72
|
if (answers.introspection) {
|
package/esm/init/index.js
CHANGED
|
@@ -18,10 +18,11 @@ export async function init() {
|
|
|
18
18
|
const config = {
|
|
19
19
|
overwrite: true,
|
|
20
20
|
schema: answers.schema,
|
|
21
|
-
documents: answers.targets.includes(Tags.
|
|
21
|
+
documents: answers.targets.includes(Tags.client) ? answers.documents : undefined,
|
|
22
22
|
generates: {
|
|
23
23
|
[answers.output]: {
|
|
24
|
-
|
|
24
|
+
preset: answers.targets.includes(Tags.client) ? 'client' : undefined,
|
|
25
|
+
plugins: answers.plugins ? answers.plugins.map(p => p.value) : [],
|
|
25
26
|
},
|
|
26
27
|
},
|
|
27
28
|
};
|
|
@@ -37,7 +38,7 @@ export async function init() {
|
|
|
37
38
|
// Emit status to the terminal
|
|
38
39
|
log(`
|
|
39
40
|
Config file generated at ${bold(relativePath)}
|
|
40
|
-
|
|
41
|
+
|
|
41
42
|
${bold('$ npm install')}
|
|
42
43
|
|
|
43
44
|
To install the plugins.
|
package/esm/init/plugins.js
CHANGED
|
@@ -15,7 +15,7 @@ export const plugins = [
|
|
|
15
15
|
package: '@graphql-codegen/typescript-operations',
|
|
16
16
|
value: 'typescript-operations',
|
|
17
17
|
pathInRepo: 'typescript/operations',
|
|
18
|
-
available: tags => allOf(tags, Tags.
|
|
18
|
+
available: tags => allOf(tags, Tags.client, Tags.typescript) || hasTag(Tags.stencil)(tags),
|
|
19
19
|
shouldBeSelected: tags => oneOf(tags, Tags.angular, Tags.stencil) || allOf(tags, Tags.typescript, Tags.react),
|
|
20
20
|
defaultExtension: '.ts',
|
|
21
21
|
},
|
|
@@ -42,7 +42,7 @@ export const plugins = [
|
|
|
42
42
|
package: '@graphql-codegen/flow-operations',
|
|
43
43
|
value: 'flow-operations',
|
|
44
44
|
pathInRepo: 'flow/operations',
|
|
45
|
-
available: tags => allOf(tags, Tags.
|
|
45
|
+
available: tags => allOf(tags, Tags.client, Tags.flow),
|
|
46
46
|
shouldBeSelected: tags => noneOf(tags, Tags.typescript),
|
|
47
47
|
defaultExtension: '.js',
|
|
48
48
|
},
|
|
@@ -55,42 +55,6 @@ export const plugins = [
|
|
|
55
55
|
shouldBeSelected: tags => noneOf(tags, Tags.typescript),
|
|
56
56
|
defaultExtension: '.js',
|
|
57
57
|
},
|
|
58
|
-
{
|
|
59
|
-
name: `TypeScript Apollo Angular ${italic('(typed GQL services)')}`,
|
|
60
|
-
package: '@graphql-codegen/typescript-apollo-angular',
|
|
61
|
-
value: 'typescript-apollo-angular',
|
|
62
|
-
pathInRepo: 'typescript/apollo-angular',
|
|
63
|
-
available: hasTag(Tags.angular),
|
|
64
|
-
shouldBeSelected: () => true,
|
|
65
|
-
defaultExtension: '.js',
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: `TypeScript Vue Apollo Composition API ${italic('(typed functions)')}`,
|
|
69
|
-
package: '@graphql-codegen/typescript-vue-apollo',
|
|
70
|
-
value: 'typescript-vue-apollo',
|
|
71
|
-
pathInRepo: 'typescript/vue-apollo',
|
|
72
|
-
available: tags => allOf(tags, Tags.vue, Tags.typescript),
|
|
73
|
-
shouldBeSelected: () => true,
|
|
74
|
-
defaultExtension: '.ts',
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: `TypeScript Vue Apollo Smart Operations ${italic('(typed functions)')}`,
|
|
78
|
-
package: '@graphql-codegen/typescript-vue-apollo-smart-ops',
|
|
79
|
-
value: 'typescript-vue-apollo-smart-ops',
|
|
80
|
-
pathInRepo: 'typescript/vue-apollo-smart-ops',
|
|
81
|
-
available: tags => allOf(tags, Tags.vue, Tags.typescript),
|
|
82
|
-
shouldBeSelected: () => true,
|
|
83
|
-
defaultExtension: '.ts',
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: `TypeScript React Apollo ${italic('(typed components and HOCs)')}`,
|
|
87
|
-
package: '@graphql-codegen/typescript-react-apollo',
|
|
88
|
-
value: 'typescript-react-apollo',
|
|
89
|
-
pathInRepo: 'typescript/react-apollo',
|
|
90
|
-
available: tags => allOf(tags, Tags.react, Tags.typescript),
|
|
91
|
-
shouldBeSelected: () => true,
|
|
92
|
-
defaultExtension: '.tsx',
|
|
93
|
-
},
|
|
94
58
|
{
|
|
95
59
|
name: `TypeScript Stencil Apollo ${italic('(typed components)')}`,
|
|
96
60
|
package: '@graphql-codegen/typescript-stencil-apollo',
|
|
@@ -114,7 +78,7 @@ export const plugins = [
|
|
|
114
78
|
package: '@graphql-codegen/typescript-graphql-files-modules',
|
|
115
79
|
value: 'typescript-graphql-files-modules',
|
|
116
80
|
pathInRepo: 'typescript/graphql-files-modules',
|
|
117
|
-
available: tags => allOf(tags, Tags.
|
|
81
|
+
available: tags => allOf(tags, Tags.client, Tags.typescript) || hasTag(Tags.stencil)(tags),
|
|
118
82
|
shouldBeSelected: () => false,
|
|
119
83
|
defaultExtension: '.ts',
|
|
120
84
|
},
|
|
@@ -123,7 +87,7 @@ export const plugins = [
|
|
|
123
87
|
package: '@graphql-codegen/typescript-document-nodes',
|
|
124
88
|
value: 'typescript-document-nodes',
|
|
125
89
|
pathInRepo: 'typescript/document-nodes',
|
|
126
|
-
available: tags => allOf(tags, Tags.typescript),
|
|
90
|
+
available: tags => allOf(tags, Tags.typescript) || hasTag(Tags.stencil)(tags),
|
|
127
91
|
shouldBeSelected: () => false,
|
|
128
92
|
defaultExtension: '.ts',
|
|
129
93
|
},
|
|
@@ -132,7 +96,7 @@ export const plugins = [
|
|
|
132
96
|
package: '@graphql-codegen/fragment-matcher',
|
|
133
97
|
value: 'fragment-matcher',
|
|
134
98
|
pathInRepo: 'other/fragment-matcher',
|
|
135
|
-
available: hasTag(Tags.
|
|
99
|
+
available: tags => hasTag(Tags.client)(tags) || hasTag(Tags.stencil)(tags),
|
|
136
100
|
shouldBeSelected: () => false,
|
|
137
101
|
defaultExtension: '.ts',
|
|
138
102
|
},
|
|
@@ -141,7 +105,7 @@ export const plugins = [
|
|
|
141
105
|
package: '@graphql-codegen/urql-introspection',
|
|
142
106
|
value: 'urql-introspection',
|
|
143
107
|
pathInRepo: 'other/urql-introspection',
|
|
144
|
-
available: hasTag(Tags.
|
|
108
|
+
available: tags => hasTag(Tags.client)(tags) || hasTag(Tags.stencil)(tags),
|
|
145
109
|
shouldBeSelected: () => false,
|
|
146
110
|
defaultExtension: '.ts',
|
|
147
111
|
},
|
package/esm/init/questions.js
CHANGED
|
@@ -4,11 +4,12 @@ import { plugins } from './plugins.js';
|
|
|
4
4
|
export function getQuestions(possibleTargets) {
|
|
5
5
|
return [
|
|
6
6
|
{
|
|
7
|
-
type: '
|
|
7
|
+
type: 'list',
|
|
8
8
|
name: 'targets',
|
|
9
9
|
message: `What type of application are you building?`,
|
|
10
10
|
choices: getApplicationTypeChoices(possibleTargets),
|
|
11
11
|
validate: ((targets) => targets.length > 0),
|
|
12
|
+
default: getApplicationTypeChoices(possibleTargets).findIndex(c => c.checked),
|
|
12
13
|
},
|
|
13
14
|
{
|
|
14
15
|
type: 'input',
|
|
@@ -26,14 +27,20 @@ export function getQuestions(possibleTargets) {
|
|
|
26
27
|
// flatten targets
|
|
27
28
|
// I can't find an API in Inquirer that would do that
|
|
28
29
|
answers.targets = normalizeTargets(answers.targets);
|
|
29
|
-
return answers.targets.includes(Tags.
|
|
30
|
+
return answers.targets.includes(Tags.client) || answers.targets.includes(Tags.stencil);
|
|
30
31
|
},
|
|
31
|
-
default:
|
|
32
|
+
default: getDocumentsDefaultValue,
|
|
32
33
|
validate: (str) => str.length > 0,
|
|
33
34
|
},
|
|
34
35
|
{
|
|
35
36
|
type: 'checkbox',
|
|
36
37
|
name: 'plugins',
|
|
38
|
+
when: answers => {
|
|
39
|
+
// flatten targets
|
|
40
|
+
// I can't find an API in Inquirer that would do that
|
|
41
|
+
answers.targets = normalizeTargets(answers.targets);
|
|
42
|
+
return !answers.targets.includes(Tags.client);
|
|
43
|
+
},
|
|
37
44
|
message: 'Pick plugins:',
|
|
38
45
|
choices: getPluginChoices,
|
|
39
46
|
validate: ((plugins) => plugins.length > 0),
|
|
@@ -48,22 +55,24 @@ export function getQuestions(possibleTargets) {
|
|
|
48
55
|
{
|
|
49
56
|
type: 'confirm',
|
|
50
57
|
name: 'introspection',
|
|
58
|
+
default: false,
|
|
51
59
|
message: 'Do you want to generate an introspection file?',
|
|
52
60
|
},
|
|
53
61
|
{
|
|
54
62
|
type: 'input',
|
|
55
63
|
name: 'config',
|
|
56
64
|
message: 'How to name the config file?',
|
|
57
|
-
default: 'codegen.yml',
|
|
65
|
+
default: answers => (answers.targets.includes(Tags.client) ? 'codegen.ts' : 'codegen.yml'),
|
|
58
66
|
validate: (str) => {
|
|
59
67
|
const isNotEmpty = str.length > 0;
|
|
60
|
-
const hasCorrectExtension = ['json', 'yml', 'yaml'].some(ext => str.toLocaleLowerCase().endsWith(`.${ext}`));
|
|
68
|
+
const hasCorrectExtension = ['json', 'yml', 'yaml', 'js', 'ts'].some(ext => str.toLocaleLowerCase().endsWith(`.${ext}`));
|
|
61
69
|
return isNotEmpty && hasCorrectExtension;
|
|
62
70
|
},
|
|
63
71
|
},
|
|
64
72
|
{
|
|
65
73
|
type: 'input',
|
|
66
74
|
name: 'script',
|
|
75
|
+
default: 'codegen',
|
|
67
76
|
message: 'What script in package.json should run the codegen?',
|
|
68
77
|
validate: (str) => str.length > 0,
|
|
69
78
|
},
|
|
@@ -77,8 +86,9 @@ export function getApplicationTypeChoices(possibleTargets) {
|
|
|
77
86
|
else if (possibleTargets.Flow) {
|
|
78
87
|
tags.push(Tags.flow);
|
|
79
88
|
}
|
|
80
|
-
else {
|
|
81
|
-
tags.push(Tags.
|
|
89
|
+
else if (possibleTargets.Node) {
|
|
90
|
+
tags.push(Tags.typescript);
|
|
91
|
+
tags.push(Tags.flow);
|
|
82
92
|
}
|
|
83
93
|
return tags;
|
|
84
94
|
}
|
|
@@ -92,25 +102,37 @@ export function getApplicationTypeChoices(possibleTargets) {
|
|
|
92
102
|
{
|
|
93
103
|
name: 'Application built with Angular',
|
|
94
104
|
key: 'angular',
|
|
95
|
-
value: [Tags.angular, Tags.
|
|
105
|
+
value: [Tags.angular, Tags.client],
|
|
96
106
|
checked: possibleTargets.Angular,
|
|
97
107
|
},
|
|
98
108
|
{
|
|
99
109
|
name: 'Application built with React',
|
|
100
110
|
key: 'react',
|
|
101
|
-
value: withFlowOrTypescript([Tags.react, Tags.
|
|
111
|
+
value: withFlowOrTypescript([Tags.react, Tags.client]),
|
|
102
112
|
checked: possibleTargets.React,
|
|
103
113
|
},
|
|
104
114
|
{
|
|
105
115
|
name: 'Application built with Stencil',
|
|
106
116
|
key: 'stencil',
|
|
107
|
-
value: [Tags.stencil, Tags.
|
|
117
|
+
value: [Tags.stencil, Tags.typescript],
|
|
108
118
|
checked: possibleTargets.Stencil,
|
|
109
119
|
},
|
|
120
|
+
{
|
|
121
|
+
name: 'Application built with Vue',
|
|
122
|
+
key: 'vue',
|
|
123
|
+
value: [Tags.vue, Tags.client],
|
|
124
|
+
checked: possibleTargets.Vue,
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'Application using graphql-request',
|
|
128
|
+
key: 'graphqlRequest',
|
|
129
|
+
value: [Tags.graphqlRequest, Tags.client],
|
|
130
|
+
checked: possibleTargets.graphqlRequest,
|
|
131
|
+
},
|
|
110
132
|
{
|
|
111
133
|
name: 'Application built with other framework or vanilla JS',
|
|
112
134
|
key: 'client',
|
|
113
|
-
value: [Tags.
|
|
135
|
+
value: [Tags.typescript, Tags.flow],
|
|
114
136
|
checked: possibleTargets.Browser && !possibleTargets.Angular && !possibleTargets.React && !possibleTargets.Stencil,
|
|
115
137
|
},
|
|
116
138
|
];
|
|
@@ -130,6 +152,9 @@ function normalizeTargets(targets) {
|
|
|
130
152
|
return [].concat(...targets);
|
|
131
153
|
}
|
|
132
154
|
export function getOutputDefaultValue(answers) {
|
|
155
|
+
if (answers.targets.includes(Tags.client)) {
|
|
156
|
+
return 'src/gql';
|
|
157
|
+
}
|
|
133
158
|
if (answers.plugins.some(plugin => plugin.defaultExtension === '.tsx')) {
|
|
134
159
|
return 'src/generated/graphql.tsx';
|
|
135
160
|
}
|
|
@@ -138,3 +163,17 @@ export function getOutputDefaultValue(answers) {
|
|
|
138
163
|
}
|
|
139
164
|
return 'src/generated/graphql.js';
|
|
140
165
|
}
|
|
166
|
+
export function getDocumentsDefaultValue(answers) {
|
|
167
|
+
if (answers.targets.includes(Tags.vue)) {
|
|
168
|
+
return 'src/**/*.vue';
|
|
169
|
+
}
|
|
170
|
+
else if (answers.targets.includes(Tags.angular)) {
|
|
171
|
+
return 'src/**/*.ts';
|
|
172
|
+
}
|
|
173
|
+
else if (answers.targets.includes(Tags.client)) {
|
|
174
|
+
return 'src/**/*.tsx';
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
return 'src/**/*.graphql';
|
|
178
|
+
}
|
|
179
|
+
}
|
package/esm/init/targets.js
CHANGED
|
@@ -14,10 +14,11 @@ export async function guessTargets() {
|
|
|
14
14
|
[Tags.react]: isReact(dependencies),
|
|
15
15
|
[Tags.stencil]: isStencil(dependencies),
|
|
16
16
|
[Tags.vue]: isVue(dependencies),
|
|
17
|
-
[Tags.
|
|
17
|
+
[Tags.client]: false,
|
|
18
18
|
[Tags.node]: false,
|
|
19
19
|
[Tags.typescript]: isTypescript(dependencies),
|
|
20
20
|
[Tags.flow]: isFlow(dependencies),
|
|
21
|
+
[Tags.graphqlRequest]: isGraphqlRequest(dependencies),
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
24
|
function isAngular(dependencies) {
|
|
@@ -38,3 +39,6 @@ function isTypescript(dependencies) {
|
|
|
38
39
|
function isFlow(dependencies) {
|
|
39
40
|
return dependencies.includes('flow');
|
|
40
41
|
}
|
|
42
|
+
function isGraphqlRequest(dependencies) {
|
|
43
|
+
return dependencies.includes('graphql-request');
|
|
44
|
+
}
|
package/esm/init/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export var Tags;
|
|
2
2
|
(function (Tags) {
|
|
3
|
-
Tags["
|
|
3
|
+
Tags["client"] = "Browser";
|
|
4
4
|
Tags["node"] = "Node";
|
|
5
5
|
Tags["typescript"] = "TypeScript";
|
|
6
6
|
Tags["flow"] = "Flow";
|
|
@@ -8,4 +8,5 @@ export var Tags;
|
|
|
8
8
|
Tags["stencil"] = "Stencil";
|
|
9
9
|
Tags["react"] = "React";
|
|
10
10
|
Tags["vue"] = "Vue";
|
|
11
|
+
Tags["graphqlRequest"] = "graphqlRequest";
|
|
11
12
|
})(Tags || (Tags = {}));
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.3-alpha-20220927092513-40482d1aa",
|
|
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
|
+
"@babel/generator": "^7.18.13",
|
|
9
|
+
"@babel/template": "^7.18.10",
|
|
10
|
+
"@babel/types": "^7.18.13",
|
|
11
|
+
"@graphql-codegen/client-preset": "1.0.1-alpha-20220927092513-40482d1aa",
|
|
8
12
|
"@graphql-codegen/core": "2.6.2",
|
|
9
|
-
"@graphql-codegen/plugin-helpers": "
|
|
13
|
+
"@graphql-codegen/plugin-helpers": "2.8.0-alpha-20220927092513-40482d1aa",
|
|
10
14
|
"@graphql-tools/apollo-engine-loader": "^7.3.6",
|
|
11
15
|
"@graphql-tools/code-file-loader": "^7.3.1",
|
|
12
16
|
"@graphql-tools/git-loader": "^7.2.1",
|
|
@@ -17,12 +21,12 @@
|
|
|
17
21
|
"@graphql-tools/prisma-loader": "^7.2.7",
|
|
18
22
|
"@graphql-tools/url-loader": "^7.13.2",
|
|
19
23
|
"@graphql-tools/utils": "^8.9.0",
|
|
20
|
-
"@whatwg-node/fetch": "^0.
|
|
24
|
+
"@whatwg-node/fetch": "^0.3.0",
|
|
21
25
|
"ansi-escapes": "^4.3.1",
|
|
22
26
|
"chalk": "^4.1.0",
|
|
23
27
|
"chokidar": "^3.5.2",
|
|
24
28
|
"cosmiconfig": "^7.0.0",
|
|
25
|
-
"cosmiconfig-typescript-loader": "
|
|
29
|
+
"cosmiconfig-typescript-loader": "4.0.0",
|
|
26
30
|
"debounce": "^1.2.0",
|
|
27
31
|
"detect-indent": "^6.0.0",
|
|
28
32
|
"graphql-config": "^4.3.5",
|
|
@@ -8,4 +8,5 @@ export declare function getApplicationTypeChoices(possibleTargets: Record<Tags,
|
|
|
8
8
|
checked: boolean;
|
|
9
9
|
}[];
|
|
10
10
|
export declare function getPluginChoices(answers: Answers): inquirer.DistinctChoice<inquirer.AllChoiceMap<inquirer.Answers>, inquirer.AllChoiceMap<inquirer.AllChoiceMap<inquirer.Answers>>>[];
|
|
11
|
-
export declare function getOutputDefaultValue(answers: Answers): "src/generated/graphql.tsx" | "src/generated/graphql.ts" | "src/generated/graphql.cjs";
|
|
11
|
+
export declare function getOutputDefaultValue(answers: Answers): "src/gql" | "src/generated/graphql.tsx" | "src/generated/graphql.ts" | "src/generated/graphql.cjs";
|
|
12
|
+
export declare function getDocumentsDefaultValue(answers: Answers): "src/**/*.vue" | "src/**/*.ts" | "src/**/*.tsx" | "src/**/*.graphql";
|
|
@@ -8,4 +8,5 @@ export declare function getApplicationTypeChoices(possibleTargets: Record<Tags,
|
|
|
8
8
|
checked: boolean;
|
|
9
9
|
}[];
|
|
10
10
|
export declare function getPluginChoices(answers: Answers): inquirer.DistinctChoice<inquirer.AllChoiceMap<inquirer.Answers>, inquirer.AllChoiceMap<inquirer.AllChoiceMap<inquirer.Answers>>>[];
|
|
11
|
-
export declare function getOutputDefaultValue(answers: Answers): "src/generated/graphql.tsx" | "src/generated/graphql.ts" | "src/generated/graphql.js";
|
|
11
|
+
export declare function getOutputDefaultValue(answers: Answers): "src/gql" | "src/generated/graphql.tsx" | "src/generated/graphql.ts" | "src/generated/graphql.js";
|
|
12
|
+
export declare function getDocumentsDefaultValue(answers: Answers): "src/**/*.vue" | "src/**/*.ts" | "src/**/*.tsx" | "src/**/*.graphql";
|
package/typings/init/types.d.cts
CHANGED
|
@@ -10,7 +10,7 @@ export interface PluginOption {
|
|
|
10
10
|
export interface Answers {
|
|
11
11
|
targets: Tags[];
|
|
12
12
|
config: string;
|
|
13
|
-
plugins
|
|
13
|
+
plugins?: PluginOption[];
|
|
14
14
|
schema: string;
|
|
15
15
|
documents?: string;
|
|
16
16
|
output: string;
|
|
@@ -18,12 +18,13 @@ export interface Answers {
|
|
|
18
18
|
introspection: boolean;
|
|
19
19
|
}
|
|
20
20
|
export declare enum Tags {
|
|
21
|
-
|
|
21
|
+
client = "Browser",
|
|
22
22
|
node = "Node",
|
|
23
23
|
typescript = "TypeScript",
|
|
24
24
|
flow = "Flow",
|
|
25
25
|
angular = "Angular",
|
|
26
26
|
stencil = "Stencil",
|
|
27
27
|
react = "React",
|
|
28
|
-
vue = "Vue"
|
|
28
|
+
vue = "Vue",
|
|
29
|
+
graphqlRequest = "graphqlRequest"
|
|
29
30
|
}
|
package/typings/init/types.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface PluginOption {
|
|
|
10
10
|
export interface Answers {
|
|
11
11
|
targets: Tags[];
|
|
12
12
|
config: string;
|
|
13
|
-
plugins
|
|
13
|
+
plugins?: PluginOption[];
|
|
14
14
|
schema: string;
|
|
15
15
|
documents?: string;
|
|
16
16
|
output: string;
|
|
@@ -18,12 +18,13 @@ export interface Answers {
|
|
|
18
18
|
introspection: boolean;
|
|
19
19
|
}
|
|
20
20
|
export declare enum Tags {
|
|
21
|
-
|
|
21
|
+
client = "Browser",
|
|
22
22
|
node = "Node",
|
|
23
23
|
typescript = "TypeScript",
|
|
24
24
|
flow = "Flow",
|
|
25
25
|
angular = "Angular",
|
|
26
26
|
stencil = "Stencil",
|
|
27
27
|
react = "React",
|
|
28
|
-
vue = "Vue"
|
|
28
|
+
vue = "Vue",
|
|
29
|
+
graphqlRequest = "graphqlRequest"
|
|
29
30
|
}
|