@graphql-codegen/introspection 2.1.2-alpha-4a7e799f2.0 → 2.2.0-alpha-bd464a586.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/cjs/index.js +28 -0
- package/cjs/package.json +1 -0
- package/{index.mjs → esm/index.js} +3 -19
- package/package.json +23 -15
- package/{index.d.ts → typings/index.d.ts} +1 -1
- package/index.js +0 -44
package/cjs/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validate = exports.plugin = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
|
|
8
|
+
const plugin = async (schema, _documents, pluginConfig) => {
|
|
9
|
+
const cleanSchema = pluginConfig.federation ? (0, plugin_helpers_1.removeFederation)(schema) : schema;
|
|
10
|
+
const descriptions = (0, visitor_plugin_common_1.getConfigValue)(pluginConfig.descriptions, true);
|
|
11
|
+
const directiveIsRepeatable = (0, visitor_plugin_common_1.getConfigValue)(pluginConfig.directiveIsRepeatable, true);
|
|
12
|
+
const schemaDescription = (0, visitor_plugin_common_1.getConfigValue)(pluginConfig.schemaDescription, undefined);
|
|
13
|
+
const specifiedByUrl = (0, visitor_plugin_common_1.getConfigValue)(pluginConfig.specifiedByUrl, undefined);
|
|
14
|
+
const introspection = (0, graphql_1.introspectionFromSchema)(cleanSchema, {
|
|
15
|
+
descriptions,
|
|
16
|
+
directiveIsRepeatable,
|
|
17
|
+
schemaDescription,
|
|
18
|
+
specifiedByUrl,
|
|
19
|
+
});
|
|
20
|
+
return pluginConfig.minify ? JSON.stringify(introspection) : JSON.stringify(introspection, null, 2);
|
|
21
|
+
};
|
|
22
|
+
exports.plugin = plugin;
|
|
23
|
+
const validate = async (schema, documents, config, outputFile) => {
|
|
24
|
+
if ((0, path_1.extname)(outputFile) !== '.json') {
|
|
25
|
+
throw new Error(`Plugin "introspection" requires extension to be ".json"!`);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.validate = validate;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
import { introspectionFromSchema } from 'graphql';
|
|
2
2
|
import { removeFederation } from '@graphql-codegen/plugin-helpers';
|
|
3
3
|
import { extname } from 'path';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
(function (MapperKind) {
|
|
7
|
-
MapperKind[MapperKind["Namespace"] = 0] = "Namespace";
|
|
8
|
-
MapperKind[MapperKind["Default"] = 1] = "Default";
|
|
9
|
-
MapperKind[MapperKind["Regular"] = 2] = "Regular";
|
|
10
|
-
})(MapperKind || (MapperKind = {}));
|
|
11
|
-
|
|
12
|
-
const getConfigValue = (value, defaultValue) => {
|
|
13
|
-
if (value === null || value === undefined) {
|
|
14
|
-
return defaultValue;
|
|
15
|
-
}
|
|
16
|
-
return value;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const plugin = async (schema, _documents, pluginConfig) => {
|
|
4
|
+
import { getConfigValue } from '@graphql-codegen/visitor-plugin-common';
|
|
5
|
+
export const plugin = async (schema, _documents, pluginConfig) => {
|
|
20
6
|
const cleanSchema = pluginConfig.federation ? removeFederation(schema) : schema;
|
|
21
7
|
const descriptions = getConfigValue(pluginConfig.descriptions, true);
|
|
22
8
|
const directiveIsRepeatable = getConfigValue(pluginConfig.directiveIsRepeatable, true);
|
|
@@ -30,10 +16,8 @@ const plugin = async (schema, _documents, pluginConfig) => {
|
|
|
30
16
|
});
|
|
31
17
|
return pluginConfig.minify ? JSON.stringify(introspection) : JSON.stringify(introspection, null, 2);
|
|
32
18
|
};
|
|
33
|
-
const validate = async (schema, documents, config, outputFile) => {
|
|
19
|
+
export const validate = async (schema, documents, config, outputFile) => {
|
|
34
20
|
if (extname(outputFile) !== '.json') {
|
|
35
21
|
throw new Error(`Plugin "introspection" requires extension to be ".json"!`);
|
|
36
22
|
}
|
|
37
23
|
};
|
|
38
|
-
|
|
39
|
-
export { plugin, validate };
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/introspection",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-alpha-bd464a586.0",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating an introspection JSON file for a GraphQLSchema",
|
|
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"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@graphql-codegen/plugin-helpers": "2.
|
|
10
|
-
"
|
|
9
|
+
"@graphql-codegen/plugin-helpers": "^2.5.0-alpha-bd464a586.0",
|
|
10
|
+
"@graphql-codegen/visitor-plugin-common": "^2.11.0-alpha-bd464a586.0",
|
|
11
|
+
"tslib": "~2.4.0"
|
|
11
12
|
},
|
|
12
13
|
"repository": {
|
|
13
14
|
"type": "git",
|
|
@@ -15,21 +16,28 @@
|
|
|
15
16
|
"directory": "packages/plugins/other/introspection"
|
|
16
17
|
},
|
|
17
18
|
"license": "MIT",
|
|
18
|
-
"main": "index.js",
|
|
19
|
-
"module": "index.
|
|
20
|
-
"typings": "index.d.ts",
|
|
19
|
+
"main": "cjs/index.js",
|
|
20
|
+
"module": "esm/index.js",
|
|
21
|
+
"typings": "typings/index.d.ts",
|
|
21
22
|
"typescript": {
|
|
22
|
-
"definition": "index.d.ts"
|
|
23
|
+
"definition": "typings/index.d.ts"
|
|
23
24
|
},
|
|
25
|
+
"type": "module",
|
|
24
26
|
"exports": {
|
|
25
|
-
"./package.json": "./package.json",
|
|
26
27
|
".": {
|
|
27
|
-
"require":
|
|
28
|
-
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./typings/index.d.ts",
|
|
30
|
+
"default": "./cjs/index.js"
|
|
31
|
+
},
|
|
32
|
+
"import": {
|
|
33
|
+
"types": "./typings/index.d.ts",
|
|
34
|
+
"default": "./esm/index.js"
|
|
35
|
+
},
|
|
36
|
+
"default": {
|
|
37
|
+
"types": "./typings/index.d.ts",
|
|
38
|
+
"default": "./esm/index.js"
|
|
39
|
+
}
|
|
29
40
|
},
|
|
30
|
-
"
|
|
31
|
-
"require": "./*.js",
|
|
32
|
-
"import": "./*.mjs"
|
|
33
|
-
}
|
|
41
|
+
"./package.json": "./package.json"
|
|
34
42
|
}
|
|
35
|
-
}
|
|
43
|
+
}
|
package/index.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const graphql = require('graphql');
|
|
6
|
-
const pluginHelpers = require('@graphql-codegen/plugin-helpers');
|
|
7
|
-
const path = require('path');
|
|
8
|
-
|
|
9
|
-
var MapperKind;
|
|
10
|
-
(function (MapperKind) {
|
|
11
|
-
MapperKind[MapperKind["Namespace"] = 0] = "Namespace";
|
|
12
|
-
MapperKind[MapperKind["Default"] = 1] = "Default";
|
|
13
|
-
MapperKind[MapperKind["Regular"] = 2] = "Regular";
|
|
14
|
-
})(MapperKind || (MapperKind = {}));
|
|
15
|
-
|
|
16
|
-
const getConfigValue = (value, defaultValue) => {
|
|
17
|
-
if (value === null || value === undefined) {
|
|
18
|
-
return defaultValue;
|
|
19
|
-
}
|
|
20
|
-
return value;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const plugin = async (schema, _documents, pluginConfig) => {
|
|
24
|
-
const cleanSchema = pluginConfig.federation ? pluginHelpers.removeFederation(schema) : schema;
|
|
25
|
-
const descriptions = getConfigValue(pluginConfig.descriptions, true);
|
|
26
|
-
const directiveIsRepeatable = getConfigValue(pluginConfig.directiveIsRepeatable, true);
|
|
27
|
-
const schemaDescription = getConfigValue(pluginConfig.schemaDescription, undefined);
|
|
28
|
-
const specifiedByUrl = getConfigValue(pluginConfig.specifiedByUrl, undefined);
|
|
29
|
-
const introspection = graphql.introspectionFromSchema(cleanSchema, {
|
|
30
|
-
descriptions,
|
|
31
|
-
directiveIsRepeatable,
|
|
32
|
-
schemaDescription,
|
|
33
|
-
specifiedByUrl,
|
|
34
|
-
});
|
|
35
|
-
return pluginConfig.minify ? JSON.stringify(introspection) : JSON.stringify(introspection, null, 2);
|
|
36
|
-
};
|
|
37
|
-
const validate = async (schema, documents, config, outputFile) => {
|
|
38
|
-
if (path.extname(outputFile) !== '.json') {
|
|
39
|
-
throw new Error(`Plugin "introspection" requires extension to be ".json"!`);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
exports.plugin = plugin;
|
|
44
|
-
exports.validate = validate;
|