@graphql-codegen/jsdoc 2.3.6 → 3.0.0-alpha-20230524083052-08ce957b4
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 +12 -4
- package/esm/index.js +12 -4
- package/package.json +6 -3
package/cjs/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.plugin = void 0;
|
|
4
|
-
const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
|
|
5
4
|
const graphql_1 = require("graphql");
|
|
5
|
+
const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
|
|
6
6
|
const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
|
|
7
7
|
const transformScalar = (scalar) => {
|
|
8
8
|
if (visitor_plugin_common_1.DEFAULT_SCALARS[scalar] === undefined) {
|
|
@@ -31,7 +31,9 @@ const createDescriptionBlock = (nodeWithDesc) => {
|
|
|
31
31
|
};
|
|
32
32
|
const plugin = (schema, documents) => {
|
|
33
33
|
const parsedSchema = (0, plugin_helpers_1.getCachedDocumentNodeFromSchema)(schema);
|
|
34
|
-
const mappedDocuments = documents
|
|
34
|
+
const mappedDocuments = documents
|
|
35
|
+
.map(document => document.document)
|
|
36
|
+
.filter(document => document !== undefined);
|
|
35
37
|
const ast = (0, graphql_1.concatAST)([parsedSchema, ...mappedDocuments]);
|
|
36
38
|
const schemaTypes = (0, graphql_1.visit)(ast, {
|
|
37
39
|
Document: {
|
|
@@ -75,7 +77,10 @@ const plugin = (schema, documents) => {
|
|
|
75
77
|
UnionTypeDefinition: {
|
|
76
78
|
leave(node) {
|
|
77
79
|
if (node.types !== undefined) {
|
|
78
|
-
return createDocBlock([
|
|
80
|
+
return createDocBlock([
|
|
81
|
+
createDescriptionBlock(node),
|
|
82
|
+
`@typedef {(${node.types.join('|')})} ${node.name}`,
|
|
83
|
+
]);
|
|
79
84
|
}
|
|
80
85
|
return node;
|
|
81
86
|
},
|
|
@@ -167,7 +172,10 @@ const plugin = (schema, documents) => {
|
|
|
167
172
|
const values = (_a = node === null || node === void 0 ? void 0 : node.values) === null || _a === void 0 ? void 0 : _a.map(value => `"${value.name}"`).join('|');
|
|
168
173
|
/** If for some reason the enum does not contain any values we fallback to "any" or "*" */
|
|
169
174
|
const valueType = values ? `(${values})` : '*';
|
|
170
|
-
return createDocBlock([
|
|
175
|
+
return createDocBlock([
|
|
176
|
+
createDescriptionBlock(node),
|
|
177
|
+
`@typedef {${valueType}} ${node.name}`,
|
|
178
|
+
]);
|
|
171
179
|
},
|
|
172
180
|
},
|
|
173
181
|
OperationDefinition: {
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { concatAST, visit, } from 'graphql';
|
|
1
2
|
import { getCachedDocumentNodeFromSchema } from '@graphql-codegen/plugin-helpers';
|
|
2
|
-
import { visit, concatAST, } from 'graphql';
|
|
3
3
|
import { DEFAULT_SCALARS } from '@graphql-codegen/visitor-plugin-common';
|
|
4
4
|
const transformScalar = (scalar) => {
|
|
5
5
|
if (DEFAULT_SCALARS[scalar] === undefined) {
|
|
@@ -28,7 +28,9 @@ const createDescriptionBlock = (nodeWithDesc) => {
|
|
|
28
28
|
};
|
|
29
29
|
export const plugin = (schema, documents) => {
|
|
30
30
|
const parsedSchema = getCachedDocumentNodeFromSchema(schema);
|
|
31
|
-
const mappedDocuments = documents
|
|
31
|
+
const mappedDocuments = documents
|
|
32
|
+
.map(document => document.document)
|
|
33
|
+
.filter(document => document !== undefined);
|
|
32
34
|
const ast = concatAST([parsedSchema, ...mappedDocuments]);
|
|
33
35
|
const schemaTypes = visit(ast, {
|
|
34
36
|
Document: {
|
|
@@ -72,7 +74,10 @@ export const plugin = (schema, documents) => {
|
|
|
72
74
|
UnionTypeDefinition: {
|
|
73
75
|
leave(node) {
|
|
74
76
|
if (node.types !== undefined) {
|
|
75
|
-
return createDocBlock([
|
|
77
|
+
return createDocBlock([
|
|
78
|
+
createDescriptionBlock(node),
|
|
79
|
+
`@typedef {(${node.types.join('|')})} ${node.name}`,
|
|
80
|
+
]);
|
|
76
81
|
}
|
|
77
82
|
return node;
|
|
78
83
|
},
|
|
@@ -164,7 +169,10 @@ export const plugin = (schema, documents) => {
|
|
|
164
169
|
const values = (_a = node === null || node === void 0 ? void 0 : node.values) === null || _a === void 0 ? void 0 : _a.map(value => `"${value.name}"`).join('|');
|
|
165
170
|
/** If for some reason the enum does not contain any values we fallback to "any" or "*" */
|
|
166
171
|
const valueType = values ? `(${values})` : '*';
|
|
167
|
-
return createDocBlock([
|
|
172
|
+
return createDocBlock([
|
|
173
|
+
createDescriptionBlock(node),
|
|
174
|
+
`@typedef {${valueType}} ${node.name}`,
|
|
175
|
+
]);
|
|
168
176
|
},
|
|
169
177
|
},
|
|
170
178
|
OperationDefinition: {
|
package/package.json
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/jsdoc",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha-20230524083052-08ce957b4",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating JSDoc based types for GraphQL queries, mutations, subscriptions and fragments",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^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": "^
|
|
9
|
+
"@graphql-codegen/plugin-helpers": "^3.0.0",
|
|
10
10
|
"@graphql-codegen/visitor-plugin-common": "2.13.1",
|
|
11
11
|
"tslib": "~2.4.0"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/dotansimha/graphql-code-generator.git",
|
|
15
|
+
"url": "https://github.com/dotansimha/graphql-code-generator-community.git",
|
|
16
16
|
"directory": "packages/plugins/typescript/typescript"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">= 16.0.0"
|
|
21
|
+
},
|
|
19
22
|
"main": "cjs/index.js",
|
|
20
23
|
"module": "esm/index.js",
|
|
21
24
|
"typings": "typings/index.d.ts",
|