Socket
Socket
Sign inDemoInstall

@graphql-codegen/visitor-plugin-common

Package Overview
Dependencies
Maintainers
5
Versions
5954
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.7-alpha-d17a7578.20 to 1.0.7-alpha-d1ab5478.43

19

dist/commonjs/base-resolvers-visitor.js

@@ -36,15 +36,9 @@ "use strict";

}
let shouldApplyOmit = true;
let shouldApplyOmit = false;
if (this.config.mappers[typeName] && this.config.mappers[typeName].type) {
this.markMapperAsUsed(typeName);
shouldApplyOmit = false;
prev[typeName] = this.config.mappers[typeName].type;
}
else if (this.config.defaultMapper && this.config.defaultMapper.type) {
if (this.config.defaultMapper.type.includes('{T}')) {
prev[typeName] = this.config.scalars[typeName] ? this._getScalar(typeName) : this.config.defaultMapper.type.replace('{T}', this.convertName(typeName));
}
else {
prev[typeName] = this.config.defaultMapper.type;
}
else if (this.config.defaultMapper && this.config.defaultMapper.type && !this.config.defaultMapper.type.includes('{T}')) {
prev[typeName] = this.config.defaultMapper.type;
}

@@ -55,2 +49,3 @@ else if (this.config.scalars[typeName]) {

else {
shouldApplyOmit = true;
prev[typeName] = this.convertName(typeName);

@@ -78,2 +73,5 @@ }

}
if (!this.config.scalars[typeName] && !this.config.mappers[typeName] && this.config.defaultMapper && this.config.defaultMapper.type.includes('{T}')) {
prev[typeName] = this.config.defaultMapper.type.replace('{T}', prev[typeName]);
}
return prev;

@@ -355,2 +353,3 @@ }, {});

const type = this.getTypeToUse(node.name);
const possibleTypes = implementingTypes.map(name => `'${name}'`).join(' | ') || 'null';
return new utils_1.DeclarationBlock(this._declarationBlockConfig)

@@ -360,3 +359,3 @@ .export()

.withName(name, `<Context = ${this.config.contextType.type}, ParentType = ${type}>`)
.withBlock([utils_1.indent(`__resolveType: TypeResolveFn<${implementingTypes.map(name => `'${name}'`).join(' | ')}, ParentType, Context>,`), ...(node.fields || []).map((f) => f(node.name))].join('\n')).string;
.withBlock([utils_1.indent(`__resolveType: TypeResolveFn<${possibleTypes}, ParentType, Context>,`), ...(node.fields || []).map((f) => f(node.name))].join('\n')).string;
}

@@ -363,0 +362,0 @@ SchemaDefinition() {

@@ -76,2 +76,5 @@ "use strict";

const loadedFragment = this._loadedFragments.find(f => f.name === node.name.value);
if (!loadedFragment) {
throw new Error(`Unable to find fragment matching then name "${node.name.value}"! Please make sure it's loaded.`);
}
if (!this._fragments[loadedFragment.onType]) {

@@ -191,3 +194,3 @@ this._fragments[loadedFragment.onType] = [];

const typeFragments = fragments[typeName];
const interfacesFragments = schemaType.getInterfaces().filter(gqlInterface => !!interfaces[gqlInterface.name]);
const interfacesFragments = schemaType.getInterfaces === undefined ? [] : schemaType.getInterfaces().filter(gqlInterface => !!interfaces[gqlInterface.name]);
if (interfacesFragments.length > 0) {

@@ -194,0 +197,0 @@ for (const relevantInterface of interfacesFragments) {

@@ -34,15 +34,9 @@ import { BaseVisitor } from './base-visitor';

}
let shouldApplyOmit = true;
let shouldApplyOmit = false;
if (this.config.mappers[typeName] && this.config.mappers[typeName].type) {
this.markMapperAsUsed(typeName);
shouldApplyOmit = false;
prev[typeName] = this.config.mappers[typeName].type;
}
else if (this.config.defaultMapper && this.config.defaultMapper.type) {
if (this.config.defaultMapper.type.includes('{T}')) {
prev[typeName] = this.config.scalars[typeName] ? this._getScalar(typeName) : this.config.defaultMapper.type.replace('{T}', this.convertName(typeName));
}
else {
prev[typeName] = this.config.defaultMapper.type;
}
else if (this.config.defaultMapper && this.config.defaultMapper.type && !this.config.defaultMapper.type.includes('{T}')) {
prev[typeName] = this.config.defaultMapper.type;
}

@@ -53,2 +47,3 @@ else if (this.config.scalars[typeName]) {

else {
shouldApplyOmit = true;
prev[typeName] = this.convertName(typeName);

@@ -76,2 +71,5 @@ }

}
if (!this.config.scalars[typeName] && !this.config.mappers[typeName] && this.config.defaultMapper && this.config.defaultMapper.type.includes('{T}')) {
prev[typeName] = this.config.defaultMapper.type.replace('{T}', prev[typeName]);
}
return prev;

@@ -353,2 +351,3 @@ }, {});

const type = this.getTypeToUse(node.name);
const possibleTypes = implementingTypes.map(name => `'${name}'`).join(' | ') || 'null';
return new DeclarationBlock(this._declarationBlockConfig)

@@ -358,3 +357,3 @@ .export()

.withName(name, `<Context = ${this.config.contextType.type}, ParentType = ${type}>`)
.withBlock([indent(`__resolveType: TypeResolveFn<${implementingTypes.map(name => `'${name}'`).join(' | ')}, ParentType, Context>,`), ...(node.fields || []).map((f) => f(node.name))].join('\n')).string;
.withBlock([indent(`__resolveType: TypeResolveFn<${possibleTypes}, ParentType, Context>,`), ...(node.fields || []).map((f) => f(node.name))].join('\n')).string;
}

@@ -361,0 +360,0 @@ SchemaDefinition() {

@@ -74,2 +74,5 @@ import { Kind, isObjectType, isUnionType, isInterfaceType, isEnumType, isEqualType, SchemaMetaFieldDef, TypeMetaFieldDef, isScalarType, } from 'graphql';

const loadedFragment = this._loadedFragments.find(f => f.name === node.name.value);
if (!loadedFragment) {
throw new Error(`Unable to find fragment matching then name "${node.name.value}"! Please make sure it's loaded.`);
}
if (!this._fragments[loadedFragment.onType]) {

@@ -189,3 +192,3 @@ this._fragments[loadedFragment.onType] = [];

const typeFragments = fragments[typeName];
const interfacesFragments = schemaType.getInterfaces().filter(gqlInterface => !!interfaces[gqlInterface.name]);
const interfacesFragments = schemaType.getInterfaces === undefined ? [] : schemaType.getInterfaces().filter(gqlInterface => !!interfaces[gqlInterface.name]);
if (interfacesFragments.length > 0) {

@@ -192,0 +195,0 @@ for (const relevantInterface of interfacesFragments) {

{
"name": "@graphql-codegen/visitor-plugin-common",
"version": "1.0.7-alpha-d17a7578.20+d17a7578",
"version": "1.0.7-alpha-d1ab5478.43+d1ab5478",
"license": "MIT",

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

"dependencies": {
"@graphql-codegen/plugin-helpers": "1.0.7-alpha-d17a7578.20+d17a7578",
"@graphql-codegen/plugin-helpers": "1.0.7-alpha-d1ab5478.43+d1ab5478",
"auto-bind": "2.0.0",

@@ -18,11 +18,11 @@ "dependency-graph": "0.8.0",

"peerDependencies": {
"graphql": "14.2.0"
"graphql": "14.2.1"
},
"devDependencies": {
"@graphql-codegen/testing": "1.0.7-alpha-d17a7578.20+d17a7578",
"@types/graphql": "14.0.7",
"@graphql-codegen/testing": "1.0.7-alpha-d1ab5478.43+d1ab5478",
"@types/graphql": "14.2.0",
"@types/jest": "24.0.11",
"graphql": "14.2.0",
"jest": "24.5.0",
"ts-jest": "24.0.1",
"graphql": "14.2.1",
"jest": "24.7.1",
"ts-jest": "24.0.2",
"typescript": "3.4.1"

@@ -40,3 +40,3 @@ },

},
"gitHead": "d17a7578fcde8c8b9986441402fbf80bac146ea1"
"gitHead": "d1ab5478a7bbcaf54204458e4fede0b04a229efe"
}

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

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