Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@graphql-codegen/jsdoc

Package Overview
Dependencies
Maintainers
5
Versions
690
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-codegen/jsdoc - npm Package Compare versions

Comparing version 1.15.1-alpha-849662d9.10 to 1.15.1-alpha-84e0e969.31

61

index.cjs.js

@@ -15,6 +15,20 @@ 'use strict';

const createDocBlock = (lines) => {
const typedef = ['/**', ...lines.map(line => ` * ${line}`), ' */'];
const typedef = [
'/**',
...lines
.filter(t => t && t !== '')
.reduce((prev, t) => [...prev, ...t.split('\n')], [])
.map(line => ` * ${line}`),
' */',
];
const block = typedef.join('\n');
return block;
};
const createDescriptionBlock = (nodeWithDesc) => {
var _a;
if ((_a = nodeWithDesc === null || nodeWithDesc === void 0 ? void 0 : nodeWithDesc.description) === null || _a === void 0 ? void 0 : _a.value) {
return `@description ${nodeWithDesc.description.value}`;
}
return '';
};
const plugin = (schema, documents) => {

@@ -33,9 +47,27 @@ const parsedSchema = graphql.parse(graphql.printSchema(schema));

const typedNode = node;
return createDocBlock([`@typedef {Object} ${typedNode.name}`, ...typedNode.fields]);
return createDocBlock([
`@typedef {Object} ${typedNode.name}`,
createDescriptionBlock(node),
...typedNode.fields,
]);
},
},
InputObjectTypeDefinition: {
leave(node) {
const typedNode = node;
return createDocBlock([
`@typedef {Object} ${typedNode.name}`,
createDescriptionBlock(node),
...typedNode.fields,
]);
},
},
InterfaceTypeDefinition: {
leave(node) {
const typedNode = node;
return createDocBlock([`@typedef {Object} ${typedNode.name}`, ...typedNode.fields]);
return createDocBlock([
`@typedef {Object} ${typedNode.name}`,
createDescriptionBlock(node),
...typedNode.fields,
]);
},

@@ -46,5 +78,3 @@ },

if (node.types !== undefined) {
return `/**
* @typedef {(${node.types.join('|')})} ${node.name}
*/`;
return createDocBlock([`@typedef {(${node.types.join('|')})} ${node.name}`, createDescriptionBlock(node)]);
}

@@ -81,5 +111,17 @@ return node;

const fieldName = node.nonNullable ? node.name : `[${node.name}]`;
return `@property {${node.type}} ${fieldName}`;
return `@property {${node.type}} ${fieldName}${node.description && node.description.value ? ` - ${node.description.value}` : ''}`;
},
},
InputValueDefinition: {
enter(node) {
if (node.type.kind === 'NonNullType') {
return { ...node, nonNullable: true };
}
return node;
},
leave(node) {
const fieldName = node.nonNullable ? node.name : `[${node.name}]`;
return `@property {${node.type}} ${fieldName}${node.description && node.description.value ? ` - ${node.description.value}` : ''}`;
},
},
ListType: {

@@ -99,3 +141,3 @@ enter(node) {

leave(node) {
return createDocBlock([`@typedef {*} ${node.name}`]);
return createDocBlock([`@typedef {*} ${node.name}`, createDescriptionBlock(node)]);
},

@@ -108,3 +150,4 @@ },

'@readonly',
...(node.values || []).map(v => `@property {String} ${v.name}`),
createDescriptionBlock(node),
...(node.values || []).map(v => `@property {String} ${v.name}${v.description && v.description.value ? ` - ${v.description.value}` : ''}`),
]);

@@ -111,0 +154,0 @@ },

@@ -11,6 +11,20 @@ import { parse, printSchema, concatAST, visit } from 'graphql';

const createDocBlock = (lines) => {
const typedef = ['/**', ...lines.map(line => ` * ${line}`), ' */'];
const typedef = [
'/**',
...lines
.filter(t => t && t !== '')
.reduce((prev, t) => [...prev, ...t.split('\n')], [])
.map(line => ` * ${line}`),
' */',
];
const block = typedef.join('\n');
return block;
};
const createDescriptionBlock = (nodeWithDesc) => {
var _a;
if ((_a = nodeWithDesc === null || nodeWithDesc === void 0 ? void 0 : nodeWithDesc.description) === null || _a === void 0 ? void 0 : _a.value) {
return `@description ${nodeWithDesc.description.value}`;
}
return '';
};
const plugin = (schema, documents) => {

@@ -29,9 +43,27 @@ const parsedSchema = parse(printSchema(schema));

const typedNode = node;
return createDocBlock([`@typedef {Object} ${typedNode.name}`, ...typedNode.fields]);
return createDocBlock([
`@typedef {Object} ${typedNode.name}`,
createDescriptionBlock(node),
...typedNode.fields,
]);
},
},
InputObjectTypeDefinition: {
leave(node) {
const typedNode = node;
return createDocBlock([
`@typedef {Object} ${typedNode.name}`,
createDescriptionBlock(node),
...typedNode.fields,
]);
},
},
InterfaceTypeDefinition: {
leave(node) {
const typedNode = node;
return createDocBlock([`@typedef {Object} ${typedNode.name}`, ...typedNode.fields]);
return createDocBlock([
`@typedef {Object} ${typedNode.name}`,
createDescriptionBlock(node),
...typedNode.fields,
]);
},

@@ -42,5 +74,3 @@ },

if (node.types !== undefined) {
return `/**
* @typedef {(${node.types.join('|')})} ${node.name}
*/`;
return createDocBlock([`@typedef {(${node.types.join('|')})} ${node.name}`, createDescriptionBlock(node)]);
}

@@ -77,5 +107,17 @@ return node;

const fieldName = node.nonNullable ? node.name : `[${node.name}]`;
return `@property {${node.type}} ${fieldName}`;
return `@property {${node.type}} ${fieldName}${node.description && node.description.value ? ` - ${node.description.value}` : ''}`;
},
},
InputValueDefinition: {
enter(node) {
if (node.type.kind === 'NonNullType') {
return { ...node, nonNullable: true };
}
return node;
},
leave(node) {
const fieldName = node.nonNullable ? node.name : `[${node.name}]`;
return `@property {${node.type}} ${fieldName}${node.description && node.description.value ? ` - ${node.description.value}` : ''}`;
},
},
ListType: {

@@ -95,3 +137,3 @@ enter(node) {

leave(node) {
return createDocBlock([`@typedef {*} ${node.name}`]);
return createDocBlock([`@typedef {*} ${node.name}`, createDescriptionBlock(node)]);
},

@@ -104,3 +146,4 @@ },

'@readonly',
...(node.values || []).map(v => `@property {String} ${v.name}`),
createDescriptionBlock(node),
...(node.values || []).map(v => `@property {String} ${v.name}${v.description && v.description.value ? ` - ${v.description.value}` : ''}`),
]);

@@ -107,0 +150,0 @@ },

6

package.json
{
"name": "@graphql-codegen/jsdoc",
"version": "1.15.1-alpha-849662d9.10+849662d9",
"version": "1.15.1-alpha-84e0e969.31+84e0e969",
"description": "GraphQL Code Generator plugin for generating JSDoc based types for GraphQL queries, mutations, subscriptions and fragments",

@@ -9,4 +9,4 @@ "peerDependencies": {

"dependencies": {
"@graphql-codegen/plugin-helpers": "1.15.1-alpha-849662d9.10+849662d9",
"@graphql-codegen/visitor-plugin-common": "1.15.1-alpha-849662d9.10+849662d9",
"@graphql-codegen/plugin-helpers": "1.15.1-alpha-84e0e969.31+84e0e969",
"@graphql-codegen/visitor-plugin-common": "1.15.1-alpha-84e0e969.31+84e0e969",
"tslib": "~2.0.0"

@@ -13,0 +13,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc