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

graphql-codegen-visitor-plugin-common

Package Overview
Dependencies
Maintainers
1
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-codegen-visitor-plugin-common - npm Package Compare versions

Comparing version 0.19.0-alpha.6a3f1430 to 0.19.0-alpha.7ed9765d

7

dist/base-documents-visitor.js

@@ -83,7 +83,10 @@ "use strict";

if (name) {
return this.convertName(node);
return this.convertName(node, {
useTypesPrefix: false
});
}
return this.convertName(this._unnamedCounter++ + '', {
prefix: 'Unnamed_',
suffix: '_'
suffix: '_',
useTypesPrefix: false
});

@@ -90,0 +93,0 @@ };

@@ -38,2 +38,5 @@ import { ScalarsMap, NamingConvention, ConvertFn, ConvertOptions } from './types';

};
protected _collectedDirectiveResolvers: {
[key: string]: string;
};
protected _variablesTransfomer: OperationVariablesToObject;

@@ -52,4 +55,5 @@ constructor(rawConfig: TRawConfig, additionalConfig: TPluginConfig, _schema: GraphQLSchema, defaultScalars?: ScalarsMap);

setVariablesTransformer(variablesTransfomer: OperationVariablesToObject): void;
readonly rootResolver: string;
getRootResolver(): string;
protected formatRootResolver(schemaTypeName: string, resolverType: string): string;
getAllDirectiveResolvers(): string;
Name(node: NameNode): string;

@@ -56,0 +60,0 @@ ListType(node: ListTypeNode): string;

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

this._collectedResolvers = {};
this._collectedDirectiveResolvers = {};
this._parsedConfig = __assign({ scalars: __assign({}, (defaultScalars || scalars_1.DEFAULT_SCALARS), (rawConfig.scalars || {})), convert: naming_1.convertFactory(rawConfig), typesPrefix: rawConfig.typesPrefix || '', contextType: rawConfig.contextType || 'any', mappers: this.transformMappers(rawConfig.mappers || {}) }, (additionalConfig || {}));

@@ -110,22 +111,31 @@ autoBind(this);

};
Object.defineProperty(BaseResolversVisitor.prototype, "rootResolver", {
get: function () {
var _this = this;
return new utils_1.DeclarationBlock(this._declarationBlockConfig)
.export()
.asKind('interface')
.withName(this.convertName('ResolversRoot'))
.withBlock(Object.keys(this._collectedResolvers)
.map(function (schemaTypeName) {
var resolverType = _this._collectedResolvers[schemaTypeName];
return utils_1.indent(_this.formatRootResolver(schemaTypeName, resolverType));
})
.join('\n')).string;
},
enumerable: true,
configurable: true
});
BaseResolversVisitor.prototype.getRootResolver = function () {
var _this = this;
return new utils_1.DeclarationBlock(this._declarationBlockConfig)
.export()
.asKind('type')
.withName(this.convertName('IResolvers'), "<Context = " + this.config.contextType + ">")
.withBlock(Object.keys(this._collectedResolvers)
.map(function (schemaTypeName) {
var resolverType = _this._collectedResolvers[schemaTypeName];
return utils_1.indent(_this.formatRootResolver(schemaTypeName, resolverType));
})
.join('\n')).string;
};
BaseResolversVisitor.prototype.formatRootResolver = function (schemaTypeName, resolverType) {
return schemaTypeName + "?: " + resolverType + ",";
};
BaseResolversVisitor.prototype.getAllDirectiveResolvers = function () {
var _this = this;
return new utils_1.DeclarationBlock(this._declarationBlockConfig)
.export()
.asKind('type')
.withName(this.convertName('IDirectiveResolvers'), "<Context = " + this.config.contextType + ">")
.withBlock(Object.keys(this._collectedDirectiveResolvers)
.map(function (schemaTypeName) {
var resolverType = _this._collectedDirectiveResolvers[schemaTypeName];
return utils_1.indent(_this.formatRootResolver(schemaTypeName, resolverType));
})
.join('\n')).string;
};
BaseResolversVisitor.prototype.Name = function (node) {

@@ -184,3 +194,3 @@ return node.value;

.withBlock(node.fields.map(function (f) { return f(node.name); }).join('\n'));
this._collectedResolvers[node.name] = name;
this._collectedResolvers[node.name] = name + '<Context>';
return block.string;

@@ -207,2 +217,3 @@ };

var baseName = this.convertName(node);
this._collectedResolvers[node.name] = 'GraphQLScalarType';
return new utils_1.DeclarationBlock(this._declarationBlockConfig)

@@ -224,7 +235,8 @@ .export()

: '';
this._collectedDirectiveResolvers[node.name] = directiveName + '<any, any, Context>';
return new utils_1.DeclarationBlock(this._declarationBlockConfig)
.export()
.asKind('type')
.withName(directiveName, '<Result>')
.withContent("DirectiveResolverFn<Result, { " + directiveArgs + " }, " + this.config.contextType + ">").string;
.withName(directiveName, "<Result, Parent, Context = " + this.config.contextType + ", Args = { " + directiveArgs + " }>")
.withContent("DirectiveResolverFn<Result, Parent, Context, Args>").string;
};

@@ -231,0 +243,0 @@ BaseResolversVisitor.prototype.InterfaceTypeDefinition = function (node) {

@@ -67,4 +67,2 @@ "use strict";

}
var convertTypeName = resolveConventionName('typeNames');
var convertEnumValues = resolveConventionName('enumValues');
return function (node, opts) {

@@ -75,6 +73,3 @@ var prefix = opts && opts.prefix;

var str = [prefix || '', getName(node), suffix || ''].join('');
if (kind === 'enumValues') {
return convertEnumValues(str);
}
return convertTypeName(str);
return resolveConventionName(kind)(str);
};

@@ -81,0 +76,0 @@ }

{
"name": "graphql-codegen-visitor-plugin-common",
"version": "0.19.0-alpha.6a3f1430",
"version": "0.19.0-alpha.7ed9765d",
"license": "MIT",

@@ -11,3 +11,3 @@ "scripts": {

"dependency-graph": "0.8.0",
"graphql-codegen-core": "0.19.0-alpha.6a3f1430",
"graphql-codegen-core": "0.19.0-alpha.7ed9765d",
"graphql-tag": "2.10.1"

@@ -14,0 +14,0 @@ },

Sorry, the diff of this file is not supported yet

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