New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@raynode/graphql-connector-sequelize

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@raynode/graphql-connector-sequelize - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

lib/filter-mapper.d.ts

6

lib/index.js

@@ -10,8 +10,14 @@ "use strict";

__export(require("./type-guards"));
const filter_mapper_1 = require("./filter-mapper");
const filter_parser_1 = require("./filter-parser");
const model_mapper_1 = require("./model-mapper");
const order_mapper_1 = require("./order-mapper");
const type_mapper_1 = require("./type-mapper");
exports.configuration = {
filterMapper: filter_mapper_1.filterMapper,
filterParser: filter_parser_1.filterParser,
modelMapper: model_mapper_1.modelMapper,
orderMapper: order_mapper_1.orderMapper,
typeMapper: type_mapper_1.typeMapper,
};
//# sourceMappingURL=index.js.map

8

lib/model-mapper.d.ts
import { GeneratedModelMapper } from '@raynode/graphql-connector';
import * as Sequelize from 'sequelize';
import { DataTypes } from './type-guards';
export interface SequelizeAttributeReference {
model: string;
key: string;
}
export interface SequelizeAttribute {
_autoGenerated?: boolean;
type: DataTypes;
allowNull: boolean;
primaryKey: boolean;
primaryKey?: boolean;
comment: string;
references?: SequelizeAttributeReference;
}

@@ -10,0 +16,0 @@ export declare type SequelizeAssociationTypes = 'HasOne' | 'HasMany' | 'BelongsTo' | 'BelongsToMany';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const graphql_connector_1 = require("@raynode/graphql-connector");
const createPage = (offset, limit, page) => ({
offset, limit, page,
});
exports.modelMapper = graphql_connector_1.createModelMapper((model, addAttribute, addAssociation) => {

@@ -8,2 +11,3 @@ const rawModel = model;

const attribute = rawModel.rawAttributes[name];
// if(d) console.log(JSON.stringify(attribute, null, 2))
addAttribute({

@@ -13,2 +17,3 @@ name,

nonNull: attribute.allowNull === false || attribute.primaryKey === true,
resolver: instance => instance[name],
});

@@ -18,10 +23,34 @@ });

const association = rawModel.associations[name];
const list = association.associationType === 'HasMany' || association.associationType === 'BelongsToMany';
addAssociation({
name: association.as,
model: association.target.name,
list: association.associationType === 'HasMany' || association.associationType === 'BelongsToMany',
list,
nonNull: association.associationType === 'BelongsTo' || association.associationType === 'BelongsToMany',
resolver: async (instance, args, context, info) => {
// @TODO
// this needs to correctly submit nodes and page when done!
const res = await instance[`get${association.as}`]();
return list
? {
nodes: res,
page: createPage(0, 100, 0),
} : res;
},
});
});
return {
create: async (_, { data }) => model.create(data),
delete: async () => null,
findMany: async (_, { order, where: { where = {}, include = [] } = {} }) => {
const nodes = await model.findAll({ include, where, order });
return {
nodes,
page: createPage(0, 100, 0),
};
},
findOne: async () => null,
update: async () => null,
};
});
//# sourceMappingURL=model-mapper.js.map

8

package.json
{
"name": "@raynode/graphql-connector-sequelize",
"version": "0.6.0",
"version": "0.6.1",
"description": "",

@@ -32,3 +32,3 @@ "main": "lib/index.js",

"keywords": [],
"author": "",
"author": "Tobias Kopelke <nox@raynode.de>",
"license": "MIT",

@@ -40,3 +40,3 @@ "bugs": {

"dependencies": {
"@raynode/graphql-connector": "^0.6.0",
"@raynode/graphql-connector": "^0.6.1",
"@types/lodash": "^4.14.118",

@@ -64,3 +64,3 @@ "@types/sequelize": "^4.27.30",

},
"gitHead": "dc8c66ec43a57b717c74af65fa91679094ac8701"
"gitHead": "eb096645c980902fcb7b89e73b433c72a14d6f18"
}

@@ -1,2 +0,2 @@

import { AnyModel, createModelMapper, GeneratedModelMapper } from '@raynode/graphql-connector'
import { AnyModel, createModelMapper, GeneratedModelMapper, Page } from '@raynode/graphql-connector'
import * as Sequelize from 'sequelize'

@@ -48,3 +48,5 @@ import { DataTypes } from './type-guards'

let d = false
const createPage = (offset: number, limit: number, page: number): Page => ({
offset, limit, page,
})

@@ -81,3 +83,3 @@ export const modelMapper = createModelMapper<DataTypes, Models>((model, addAttribute, addAssociation) => {

nodes: res,
page: null,
page: createPage(0, 100, 0),
} : res

@@ -95,3 +97,3 @@ },

nodes,
page: { limit: 100, offset: 0 },
page: createPage(0, 100, 0),
}

@@ -98,0 +100,0 @@ },

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