Socket
Socket
Sign inDemoInstall

simple-graphql

Package Overview
Dependencies
24
Maintainers
1
Versions
300
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.2.4 to 4.2.5

51

dist/build/buildFieldTypeContext.js

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

columnOptions: (schema, fieldName, options) => {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e, _f;
const foreignField = fieldName;

@@ -129,25 +129,28 @@ let onDelete = ((_b = (_a = options.metadata) === null || _a === void 0 ? void 0 : _a.column) === null || _b === void 0 ? void 0 : _b.onDelete) || 'RESTRICT';

}
if (options.nullable === false) {
schema.belongsTo({
[fieldName]: {
target: typeName,
hidden: true,
foreignField: foreignField,
foreignKey: { name: foreignField + 'Id', allowNull: false },
onDelete: onDelete,
constraints: constraints
}
});
}
else {
schema.belongsTo({
[fieldName]: {
target: typeName,
hidden: true,
foreignField: foreignField,
onDelete: onDelete,
constraints: constraints
}
});
}
schema.belongsTo({
[fieldName]: {
target: typeName,
hidden: true,
foreignField: foreignField,
foreignKey: {
name: foreignField + 'Id',
allowNull: options.nullable
},
onDelete: onDelete,
constraints: constraints
}
});
schema.belongsTo({
[fieldName]: {
target: typeName,
hidden: true,
foreignField: foreignField,
foreignKey: {
name: ((_f = (_e = options.metadata) === null || _e === void 0 ? void 0 : _e.column) === null || _f === void 0 ? void 0 : _f.field) || foreignField + 'Id',
allowNull: options.nullable !== false
},
onDelete: onDelete,
constraints: constraints
}
});
return null;

@@ -154,0 +157,0 @@ }

@@ -69,8 +69,22 @@ "use strict";

function buildModelAssociations(schemas, models) {
const getForeignKey = (config) => {
var _a, _b;
if (config.foreignKey) {
return config.foreignKey;
}
else if (config.foreignField) {
const schema = schemas.find((s) => s.name === config.target);
const field = schema === null || schema === void 0 ? void 0 : schema.config.fields[config.foreignField];
if (field) {
return ((_b = (_a = field.metadata) === null || _a === void 0 ? void 0 : _a.column) === null || _b === void 0 ? void 0 : _b.field) || config.foreignField + 'Id';
}
}
return config.foreignField + 'Id';
};
for (const schema of schemas) {
lodash_1.default.forOwn(schema.config.associations.hasMany, (config, key) => {
models[schema.name].hasMany(models[config.target], Object.assign(Object.assign({}, config), { as: key, foreignKey: config.foreignKey || config.foreignField + 'Id' }));
models[schema.name].hasMany(models[config.target], Object.assign(Object.assign({}, config), { as: key, foreignKey: getForeignKey(config) }));
});
lodash_1.default.forOwn(schema.config.associations.belongsToMany, (config, key) => {
models[schema.name].belongsToMany(models[config.target], Object.assign(Object.assign({}, config), { as: key, foreignKey: config.foreignField + 'Id',
models[schema.name].belongsToMany(models[config.target], Object.assign(Object.assign({}, config), { as: key, foreignKey: getForeignKey(config),
// through: config.through && {...config.through, model: models[config.through.model]}

@@ -80,6 +94,14 @@ through: config.through }));

lodash_1.default.forOwn(schema.config.associations.hasOne, (config, key) => {
models[schema.name].hasOne(models[config.target], Object.assign(Object.assign({}, config), { as: key, foreignKey: config.foreignKey || config.foreignField + 'Id' }));
models[schema.name].hasOne(models[config.target], Object.assign(Object.assign({}, config), { as: key, foreignKey: getForeignKey(config) }));
});
lodash_1.default.forOwn(schema.config.associations.belongsTo, (config, key) => {
models[schema.name].belongsTo(models[config.target], Object.assign(Object.assign({}, config), { as: key, foreignKey: config.foreignKey || config.foreignField + 'Id', targetKey: config.targetKey || 'id' }));
const foreignKey = getForeignKey(config);
models[schema.name].belongsTo(models[config.target], Object.assign(Object.assign({}, config), { as: key, foreignKey: foreignKey, targetKey: config.targetKey || 'id' }));
const foreignKeyName = typeof foreignKey === 'string' ? foreignKey : foreignKey.name;
if (foreignKeyName != config.foreignField + 'Id') {
models[schema.name].rawAttributes[config.foreignField + 'Id'] = {
type: 'INT(11)',
field: foreignKeyName
};
}
});

@@ -86,0 +108,0 @@ }

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

if (((_b = (_a = schema.options.tableOptions) === null || _a === void 0 ? void 0 : _a.primaryKey) === null || _b === void 0 ? void 0 : _b.autoIncrement) === false) {
attrs['id'] = args['id'];
//attrs['id'] = args['id']
}

@@ -78,0 +78,0 @@ lodash_1.default.forOwn(schema.config.fields, (value, key) => {

{
"name": "simple-graphql",
"version": "4.2.4",
"version": "4.2.5",
"description": "The simple way to generates GraphQL schemas and Sequelize models from your models definition.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc