@graphql-codegen/typescript-enum-array 3.0.0-alpha-20230925212548-cee5489c0 → 3.1.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 +3 -1
- package/esm/index.js +3 -1
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.plugin = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
4
5
|
const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
|
|
5
6
|
function getEnumTypeMap(schema) {
|
|
6
7
|
var _a;
|
|
@@ -47,7 +48,8 @@ function buildImportStatement(enums, importFrom) {
|
|
|
47
48
|
return [`import { ${names.join(', ')} } from "${importFrom}";`];
|
|
48
49
|
}
|
|
49
50
|
const plugin = (schema, _documents, config) => {
|
|
50
|
-
|
|
51
|
+
// https://github.com/graphql/graphql-js/issues/1575#issuecomment-454978897
|
|
52
|
+
const enums = getEnumTypeMap((0, graphql_1.buildSchema)((0, graphql_1.printSchema)(schema)));
|
|
51
53
|
const content = enums.map(e => buildArrayDefinition(e, config)).join('\n');
|
|
52
54
|
const result = { content };
|
|
53
55
|
if (config.importFrom) {
|
package/esm/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildSchema, printSchema } from 'graphql';
|
|
1
2
|
import { convertFactory } from '@graphql-codegen/visitor-plugin-common';
|
|
2
3
|
function getEnumTypeMap(schema) {
|
|
3
4
|
var _a;
|
|
@@ -44,7 +45,8 @@ function buildImportStatement(enums, importFrom) {
|
|
|
44
45
|
return [`import { ${names.join(', ')} } from "${importFrom}";`];
|
|
45
46
|
}
|
|
46
47
|
export const plugin = (schema, _documents, config) => {
|
|
47
|
-
|
|
48
|
+
// https://github.com/graphql/graphql-js/issues/1575#issuecomment-454978897
|
|
49
|
+
const enums = getEnumTypeMap(buildSchema(printSchema(schema)));
|
|
48
50
|
const content = enums.map(e => buildArrayDefinition(e, config)).join('\n');
|
|
49
51
|
const result = { content };
|
|
50
52
|
if (config.importFrom) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-enum-array",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for adding const array",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|