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

gql-types-generator

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gql-types-generator - npm Package Compare versions

Comparing version 1.4.4 to 1.4.5

3

dist/utils/generation.d.ts

@@ -19,6 +19,7 @@ import { ScalarsMap, Union, Enum, Entity, PreparedObject, Operation, PreparedObjectField, OperationRootNamespace, OperationNamespaceField, NamedGQLType, Scalar } from '../types';

* @param {PreparedObject} obj
* @param formatName
* @param includeDescription
* @returns {string}
*/
export declare function generatePreparedObject(obj: PreparedObject, includeDescription?: boolean): string;
export declare function generatePreparedObject(obj: PreparedObject, formatName: boolean, includeDescription?: boolean): string;
/**

@@ -25,0 +26,0 @@ * GQL entity => TS interface + namespace?

@@ -39,6 +39,7 @@ "use strict";

* @param {PreparedObject} obj
* @param formatName
* @param includeDescription
* @returns {string}
*/
function generatePreparedObject(obj, includeDescription) {
function generatePreparedObject(obj, formatName, includeDescription) {
if (includeDescription === void 0) { includeDescription = false; }

@@ -49,4 +50,5 @@ var name = obj.name, description = obj.description, fields = obj.fields;

}, '');
var formattedName = formatName ? misc_1.toCamelCase(name) : name;
return (includeDescription ? misc_1.formatDescription(description) : '')
+ ("export interface " + misc_1.toCamelCase(name) + " {\n")
+ ("export interface " + formattedName + " {\n")
+ misc_1.withSpaces(definition, 2)

@@ -71,3 +73,3 @@ + '}\n';

if (f.args !== null && f.args.fields.length > 0) {
var argsDefinition = generatePreparedObject(f.args);
var argsDefinition = generatePreparedObject(f.args, true);
acc += "export namespace " + f.name + " {\n"

@@ -83,3 +85,3 @@ + misc_1.withSpaces(argsDefinition, 2)

+ "\n}\n\n"
+ generatePreparedObject(fields, false);
+ generatePreparedObject(fields, false, false);
}

@@ -150,3 +152,3 @@ exports.generateEntity = generateEntity;

else {
result += generatePreparedObject(type, true);
result += generatePreparedObject(type, false, true);
if (fields && fields.length > 0) {

@@ -172,3 +174,3 @@ var content = fields.reduce(function (acc, f) {

// Namespace
var content = generatePreparedObject(args);
var content = generatePreparedObject(args, false);
fields.forEach(function (f) {

@@ -206,3 +208,3 @@ content += generateOperationNamespaceField(f);

// Operation result interface
+ generatePreparedObject(selection)
+ generatePreparedObject(selection, true)
// Operation export

@@ -209,0 +211,0 @@ + ("export " + operationConst);

@@ -61,2 +61,10 @@ import { Enum, Scalar, Union, Entity, PreparedObject, Operation, PreparedObjectField, OperationNamespaceField, OperationRootNamespace, NamedGQLType } from '../types';

export declare function selectionSetToNamespaceFields(selectionSet: SelectionSetNode, rootNode: GraphQLObjectType, path?: string): OperationNamespaceField[];
/**
* Converts selection set to OperationRootNamespace
* @param {SelectionSetNode} selectionSet
* @param {string} compiledName
* @param {PreparedObject} args
* @param {GraphQLObjectType} rootNode
* @returns {OperationRootNamespace}
*/
export declare function selectionSetToRootNamespace(selectionSet: SelectionSetNode, compiledName: string, args: PreparedObject, rootNode: GraphQLObjectType): OperationRootNamespace;

@@ -63,0 +71,0 @@ /**

@@ -69,3 +69,2 @@ "use strict";

var fieldName = f.name, type = f.type, fieldDescription = f.description, args = f.args;
var formattedFieldName = misc_1.toCamelCase(fieldName);
// Fields

@@ -75,3 +74,3 @@ acc.fields.fields.push({

description: fieldDescription,
type: formattedName + "." + formattedFieldName,
type: formattedName + "." + fieldName,
});

@@ -107,3 +106,3 @@ // Arguments

acc.namespace.fields.push({
name: formattedFieldName,
name: fieldName,
description: fieldDescription,

@@ -140,3 +139,2 @@ args: preparedArguments,

var fieldName = f.name, type = f.type, fieldDescription = f.description;
var formattedFieldName = misc_1.toCamelCase(fieldName);
// Fields

@@ -146,3 +144,3 @@ acc.fields.fields.push({

description: fieldDescription,
type: formattedName + "." + formattedFieldName,
type: formattedName + "." + fieldName,
});

@@ -158,3 +156,3 @@ // Namespace

acc.namespace.fields.push({
name: formattedFieldName,
name: fieldName,
description: fieldDescription,

@@ -268,2 +266,10 @@ args: null,

exports.selectionSetToNamespaceFields = selectionSetToNamespaceFields;
/**
* Converts selection set to OperationRootNamespace
* @param {SelectionSetNode} selectionSet
* @param {string} compiledName
* @param {PreparedObject} args
* @param {GraphQLObjectType} rootNode
* @returns {OperationRootNamespace}
*/
function selectionSetToRootNamespace(selectionSet, compiledName, args, rootNode) {

@@ -270,0 +276,0 @@ var nspFields = selectionSetToNamespaceFields(selectionSet, rootNode);

{
"name": "gql-types-generator",
"version": "1.4.4",
"version": "1.4.5",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "types": "dist/index.d.ts",

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