@graphql-codegen/import-types-preset 2.1.20 → 2.1.22-alpha-2cc8b095b.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.
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const addPlugin = _interopDefault(require('@graphql-codegen/add'));
|
|
9
|
-
|
|
10
|
-
const preset = {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.preset = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
|
|
6
|
+
const add_1 = tslib_1.__importDefault(require("@graphql-codegen/add"));
|
|
7
|
+
exports.preset = {
|
|
11
8
|
buildGeneratesSection: options => {
|
|
12
9
|
if (!options.presetConfig.typesPath) {
|
|
13
10
|
throw new Error(`Preset "import-types" requires you to specify "typesPath" configuration and point it to your base types file (generated by "typescript" plugin)!`);
|
|
@@ -15,7 +12,7 @@ const preset = {
|
|
|
15
12
|
const importTypesNamespace = options.presetConfig.importTypesNamespace || 'Types';
|
|
16
13
|
const pluginMap = {
|
|
17
14
|
...options.pluginMap,
|
|
18
|
-
add:
|
|
15
|
+
add: add_1.default,
|
|
19
16
|
};
|
|
20
17
|
const plugins = [...options.plugins];
|
|
21
18
|
const config = {
|
|
@@ -27,7 +24,7 @@ const preset = {
|
|
|
27
24
|
externalFragments: [],
|
|
28
25
|
};
|
|
29
26
|
options.documents.map(documentFile => {
|
|
30
|
-
if (
|
|
27
|
+
if ((0, plugin_helpers_1.isUsingTypes)(documentFile.document, config.externalFragments.map(m => m.name), options.schemaAst)) {
|
|
31
28
|
const importType = options.config.useTypeImports ? 'import type' : 'import';
|
|
32
29
|
plugins.unshift({
|
|
33
30
|
add: {
|
|
@@ -49,6 +46,4 @@ const preset = {
|
|
|
49
46
|
];
|
|
50
47
|
},
|
|
51
48
|
};
|
|
52
|
-
|
|
53
|
-
exports.default = preset;
|
|
54
|
-
exports.preset = preset;
|
|
49
|
+
exports.default = exports.preset;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { isUsingTypes } from '@graphql-codegen/plugin-helpers';
|
|
2
2
|
import addPlugin from '@graphql-codegen/add';
|
|
3
|
-
|
|
4
|
-
const preset = {
|
|
3
|
+
export const preset = {
|
|
5
4
|
buildGeneratesSection: options => {
|
|
6
5
|
if (!options.presetConfig.typesPath) {
|
|
7
6
|
throw new Error(`Preset "import-types" requires you to specify "typesPath" configuration and point it to your base types file (generated by "typescript" plugin)!`);
|
|
@@ -43,6 +42,4 @@ const preset = {
|
|
|
43
42
|
];
|
|
44
43
|
},
|
|
45
44
|
};
|
|
46
|
-
|
|
47
45
|
export default preset;
|
|
48
|
-
export { preset };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/import-types-preset",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.22-alpha-2cc8b095b.0",
|
|
4
4
|
"description": "GraphQL Code Generator preset for importing types to operation file",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"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"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@graphql-codegen/add": "^3.1.1",
|
|
10
10
|
"@graphql-codegen/plugin-helpers": "^2.4.0",
|
|
11
|
-
"@graphql-codegen/visitor-plugin-common": "2.
|
|
11
|
+
"@graphql-codegen/visitor-plugin-common": "2.11.0-alpha-2cc8b095b.0",
|
|
12
12
|
"tslib": "~2.4.0"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
@@ -17,21 +17,28 @@
|
|
|
17
17
|
"directory": "packages/presets/import-types"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
|
-
"main": "index.js",
|
|
21
|
-
"module": "index.
|
|
22
|
-
"typings": "index.d.ts",
|
|
20
|
+
"main": "cjs/index.js",
|
|
21
|
+
"module": "esm/index.js",
|
|
22
|
+
"typings": "typings/index.d.ts",
|
|
23
23
|
"typescript": {
|
|
24
|
-
"definition": "index.d.ts"
|
|
24
|
+
"definition": "typings/index.d.ts"
|
|
25
25
|
},
|
|
26
|
+
"type": "module",
|
|
26
27
|
"exports": {
|
|
27
|
-
"./package.json": "./package.json",
|
|
28
28
|
".": {
|
|
29
|
-
"require":
|
|
30
|
-
|
|
29
|
+
"require": {
|
|
30
|
+
"types": "./typings/index.d.ts",
|
|
31
|
+
"default": "./cjs/index.js"
|
|
32
|
+
},
|
|
33
|
+
"import": {
|
|
34
|
+
"types": "./typings/index.d.ts",
|
|
35
|
+
"default": "./esm/index.js"
|
|
36
|
+
},
|
|
37
|
+
"default": {
|
|
38
|
+
"types": "./typings/index.d.ts",
|
|
39
|
+
"default": "./esm/index.js"
|
|
40
|
+
}
|
|
31
41
|
},
|
|
32
|
-
"
|
|
33
|
-
"require": "./*.js",
|
|
34
|
-
"import": "./*.mjs"
|
|
35
|
-
}
|
|
42
|
+
"./package.json": "./package.json"
|
|
36
43
|
}
|
|
37
|
-
}
|
|
44
|
+
}
|
|
File without changes
|