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
5
Versions
6023
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 1.0.3-alpha-8c52a7b7.4 to 1.0.3-alpha-8cb7f4a1.2

45

dist/commonjs/base-resolvers-visitor.d.ts

@@ -13,4 +13,2 @@ import { ParsedConfig, RawConfig, BaseVisitor } from './base-visitor';

};
defaultMapper: ParsedMapper;
avoidOptionals: boolean;
}

@@ -58,44 +56,2 @@ export interface RawResolversConfig extends RawConfig {

};
/**
* @name defaultMapper
* @type string
* @description Allow you to set the default mapper when it's not being override by `mappers` or generics.
* You can specify a type name, or specify a string in `module#type` format.
* The defualt value of mappers it the TypeScript type generated by `typescript` package.
*
* @example Replace with any
* ```yml
* plugins
* config:
* defaultMapper: any
* ```
*
* @example Custom Base Object
* ```yml
* plugins
* config:
* defaultMapper: ./my-file#BaseObject
* ```
*/
defaultMapper?: string;
/**
* @name avoidOptionals
* @type boolean
* @description This will cause the generator to avoid using TypeScript optionals (`?`),
* so all field resolvers must be implemented in order to avoid compilation errors.
*
* @default false
*
* @example
* ```yml
* generates:
* path/to/file.ts:
* plugins:
* - typescript
* - typescript-resolvers
* config:
* avoidOptionals: true
* ```
*/
avoidOptionals?: boolean;
}

@@ -115,3 +71,2 @@ export declare class BaseResolversVisitor<TRawConfig extends RawResolversConfig = RawResolversConfig, TPluginConfig extends ParsedResolversConfig = ParsedResolversConfig> extends BaseVisitor<TRawConfig, TPluginConfig> {

readonly schema: GraphQLSchema;
readonly defaultMapperType: string;
readonly mappersImports: string[];

@@ -118,0 +73,0 @@ protected buildMapperImport(source: string, types: string[]): string;

15

dist/commonjs/base-resolvers-visitor.js

@@ -12,3 +12,3 @@ "use strict";

constructor(rawConfig, additionalConfig, _schema, defaultScalars = scalars_1.DEFAULT_SCALARS) {
super(rawConfig, Object.assign({ contextType: mappers_1.parseMapper(rawConfig.contextType || 'any'), avoidOptionals: utils_1.getConfigValue(rawConfig.avoidOptionals, false), defaultMapper: rawConfig.defaultMapper ? mappers_1.parseMapper(rawConfig.defaultMapper || 'any') : null, mappers: mappers_1.transformMappers(rawConfig.mappers || {}) }, (additionalConfig || {})), utils_1.buildScalars(_schema, defaultScalars));
super(rawConfig, Object.assign({ contextType: mappers_1.parseMapper(rawConfig.contextType || 'any'), mappers: mappers_1.transformMappers(rawConfig.mappers || {}) }, (additionalConfig || {})), utils_1.buildScalars(_schema, defaultScalars));
this._schema = _schema;

@@ -24,5 +24,2 @@ this._declarationBlockConfig = {};

}
get defaultMapperType() {
return this.config.defaultMapper.type;
}
get mappersImports() {

@@ -47,8 +44,2 @@ const groupedMappers = {};

}
if (this.config.defaultMapper && this.config.defaultMapper.isExternal) {
if (!groupedMappers[this.config.defaultMapper.source]) {
groupedMappers[this.config.defaultMapper.source] = [];
}
groupedMappers[this.config.defaultMapper.source].push(this.config.defaultMapper.type);
}
return Object.keys(groupedMappers).map(source => this.buildMapperImport(source, groupedMappers[source]));

@@ -78,3 +69,3 @@ }

formatRootResolver(schemaTypeName, resolverType) {
return `${schemaTypeName}${this.config.avoidOptionals ? '' : '?'}: ${resolverType},`;
return `${schemaTypeName}?: ${resolverType},`;
}

@@ -125,3 +116,3 @@ getAllDirectiveResolvers() {

const isSubscriptionType = subscriptionType && subscriptionType.name === parentName;
return utils_1.indent(`${node.name}${this.config.avoidOptionals ? '' : '?'}: ${isSubscriptionType ? 'SubscriptionResolver' : 'Resolver'}<${mappedType}, ParentType, Context${hasArguments
return utils_1.indent(`${node.name}?: ${isSubscriptionType ? 'SubscriptionResolver' : 'Resolver'}<${mappedType}, ParentType, Context${hasArguments
? `, ${this.convertName(parentName, {

@@ -128,0 +119,0 @@ useTypesPrefix: true,

@@ -13,4 +13,2 @@ import { ParsedConfig, RawConfig, BaseVisitor } from './base-visitor';

};
defaultMapper: ParsedMapper;
avoidOptionals: boolean;
}

@@ -58,44 +56,2 @@ export interface RawResolversConfig extends RawConfig {

};
/**
* @name defaultMapper
* @type string
* @description Allow you to set the default mapper when it's not being override by `mappers` or generics.
* You can specify a type name, or specify a string in `module#type` format.
* The defualt value of mappers it the TypeScript type generated by `typescript` package.
*
* @example Replace with any
* ```yml
* plugins
* config:
* defaultMapper: any
* ```
*
* @example Custom Base Object
* ```yml
* plugins
* config:
* defaultMapper: ./my-file#BaseObject
* ```
*/
defaultMapper?: string;
/**
* @name avoidOptionals
* @type boolean
* @description This will cause the generator to avoid using TypeScript optionals (`?`),
* so all field resolvers must be implemented in order to avoid compilation errors.
*
* @default false
*
* @example
* ```yml
* generates:
* path/to/file.ts:
* plugins:
* - typescript
* - typescript-resolvers
* config:
* avoidOptionals: true
* ```
*/
avoidOptionals?: boolean;
}

@@ -115,3 +71,2 @@ export declare class BaseResolversVisitor<TRawConfig extends RawResolversConfig = RawResolversConfig, TPluginConfig extends ParsedResolversConfig = ParsedResolversConfig> extends BaseVisitor<TRawConfig, TPluginConfig> {

readonly schema: GraphQLSchema;
readonly defaultMapperType: string;
readonly mappersImports: string[];

@@ -118,0 +73,0 @@ protected buildMapperImport(source: string, types: string[]): string;

17

dist/esnext/base-resolvers-visitor.js
import { BaseVisitor } from './base-visitor';
import * as autoBind from 'auto-bind';
import { DEFAULT_SCALARS } from './scalars';
import { DeclarationBlock, indent, getBaseTypeNode, buildScalars, getConfigValue } from './utils';
import { DeclarationBlock, indent, getBaseTypeNode, buildScalars } from './utils';
import { GraphQLObjectType } from 'graphql';

@@ -10,3 +10,3 @@ import { OperationVariablesToObject } from './variables-to-object';

constructor(rawConfig, additionalConfig, _schema, defaultScalars = DEFAULT_SCALARS) {
super(rawConfig, Object.assign({ contextType: parseMapper(rawConfig.contextType || 'any'), avoidOptionals: getConfigValue(rawConfig.avoidOptionals, false), defaultMapper: rawConfig.defaultMapper ? parseMapper(rawConfig.defaultMapper || 'any') : null, mappers: transformMappers(rawConfig.mappers || {}) }, (additionalConfig || {})), buildScalars(_schema, defaultScalars));
super(rawConfig, Object.assign({ contextType: parseMapper(rawConfig.contextType || 'any'), mappers: transformMappers(rawConfig.mappers || {}) }, (additionalConfig || {})), buildScalars(_schema, defaultScalars));
this._schema = _schema;

@@ -22,5 +22,2 @@ this._declarationBlockConfig = {};

}
get defaultMapperType() {
return this.config.defaultMapper.type;
}
get mappersImports() {

@@ -45,8 +42,2 @@ const groupedMappers = {};

}
if (this.config.defaultMapper && this.config.defaultMapper.isExternal) {
if (!groupedMappers[this.config.defaultMapper.source]) {
groupedMappers[this.config.defaultMapper.source] = [];
}
groupedMappers[this.config.defaultMapper.source].push(this.config.defaultMapper.type);
}
return Object.keys(groupedMappers).map(source => this.buildMapperImport(source, groupedMappers[source]));

@@ -76,3 +67,3 @@ }

formatRootResolver(schemaTypeName, resolverType) {
return `${schemaTypeName}${this.config.avoidOptionals ? '' : '?'}: ${resolverType},`;
return `${schemaTypeName}?: ${resolverType},`;
}

@@ -123,3 +114,3 @@ getAllDirectiveResolvers() {

const isSubscriptionType = subscriptionType && subscriptionType.name === parentName;
return indent(`${node.name}${this.config.avoidOptionals ? '' : '?'}: ${isSubscriptionType ? 'SubscriptionResolver' : 'Resolver'}<${mappedType}, ParentType, Context${hasArguments
return indent(`${node.name}?: ${isSubscriptionType ? 'SubscriptionResolver' : 'Resolver'}<${mappedType}, ParentType, Context${hasArguments
? `, ${this.convertName(parentName, {

@@ -126,0 +117,0 @@ useTypesPrefix: true,

{
"name": "@graphql-codegen/visitor-plugin-common",
"version": "1.0.3-alpha-8c52a7b7.4+8c52a7b7",
"version": "1.0.3-alpha-8cb7f4a1.2+8cb7f4a1",
"license": "MIT",

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

"dependencies": {
"@graphql-codegen/plugin-helpers": "1.0.3-alpha-8c52a7b7.4+8c52a7b7",
"@graphql-codegen/plugin-helpers": "1.0.3-alpha-8cb7f4a1.2+8cb7f4a1",
"auto-bind": "2.0.0",

@@ -20,3 +20,3 @@ "dependency-graph": "0.8.0",

"devDependencies": {
"@graphql-codegen/testing": "1.0.3-alpha-8c52a7b7.4+8c52a7b7",
"@graphql-codegen/testing": "1.0.3-alpha-8cb7f4a1.2+8cb7f4a1",
"@types/graphql": "14.0.7",

@@ -36,3 +36,3 @@ "graphql": "14.1.1",

},
"gitHead": "8c52a7b7e0a2210cf25e5dbf9aeed4d8adbc8706"
"gitHead": "8cb7f4a18670d8903913107c38890bef7543c9f7"
}

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