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.3 to 0.7.1

2

lib/filter-parser.d.ts

@@ -0,3 +1,3 @@

import { FilterParser } from '@raynode/graphql-connector';
import * as Sequelize from 'sequelize';
import { FilterParser } from '@raynode/graphql-connector';
import { Models, SequelizeModel } from './model-mapper';

@@ -4,0 +4,0 @@ import { DataTypes } from './type-guards';

@@ -56,10 +56,10 @@ "use strict";

exports.filterParser = (mode, model, name, value, data) => {
const filter = { where: data.where || {}, include: data.include || [] };
// convert all where-filters into the correct sequelize groups
if (mode === 'where')
return exports.parser(model, name, value, filter);
return exports.parser(model, name, value, { where: data.where || {}, include: data.include || [] });
data[name] = value;
// @TODO create
// @TODO update
return filter;
return data;
};
//# sourceMappingURL=filter-parser.js.map

@@ -41,16 +41,25 @@ "use strict";

});
return {
const findAll = async (include, where, order) => {
const nodes = await model.findAll({ include, where, order });
return {
nodes,
page: createPage(0, 100, 0),
};
};
const resolvers = {
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),
};
delete: async (_, { where: { where } }) => {
const deletedItems = await model.findAll({ where });
await model.destroy({ where });
return deletedItems;
},
findOne: async () => null,
update: async () => null,
findMany: async (_, { order, where: { where = {}, include = [] } = {} }) => findAll(include, where, order),
findOne: async (_, { order, where: { where = {}, include = [] } = {} }) => model.findOne({ include, where, order }),
update: async (_, { data, where: { where, include } }) => {
await model.update(data, { where });
return model.findAll({ where });
},
};
return resolvers;
});
//# sourceMappingURL=model-mapper.js.map
{
"name": "@raynode/graphql-connector-sequelize",
"version": "0.6.3",
"version": "0.7.1",
"description": "",

@@ -26,4 +26,4 @@ "main": "lib/index.js",

"src/**/*.{ts,tsx}": [
"prettier --write",
"tslint --fix",
"prettier --write",
"git add"

@@ -40,3 +40,3 @@ ]

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

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

},
"gitHead": "a9713c18c15004be4662109b6c2b8087cf81ec54"
"gitHead": "e8074965bbf0160a662621d9b524a4b64bf95d80"
}

@@ -13,5 +13,5 @@

GraphQLInt,
isEnumType,
isListType,
isScalarType,
isEnumType,
} from 'graphql'

@@ -18,0 +18,0 @@

import * as Sequelize from 'sequelize'
import {

@@ -7,2 +6,3 @@ FilterMapperMode,

} from '@raynode/graphql-connector'
import * as Sequelize from 'sequelize'

@@ -109,8 +109,8 @@ import { Models, SequelizeAssociation, SequelizeModel } from './model-mapper'

(mode, model: SequelizeModel, name, value, data) => {
const filter: ParsedFilter = { where: data.where || {}, include: data.include || [] }
// convert all where-filters into the correct sequelize groups
if(mode === 'where') return parser(model, name, value, filter)
if(mode === 'where') return parser(model, name, value, { where: data.where || {}, include: data.include || [] })
data[name] = value
// @TODO create
// @TODO update
return filter
return data
}
import { applyFilterParser } from '@raynode/graphql-connector'
import {

@@ -12,3 +13,2 @@ GraphQLBoolean,

} from 'graphql'
import { applyFilterParser } from '@raynode/graphql-connector'
import { filterMapper } from './filter-mapper'

@@ -84,8 +84,4 @@ import { filterParser } from './filter-parser'

}})
console.log('shift')
console.log('shift')
console.log('shift')
})
})
})

@@ -0,9 +1,9 @@

import { createBaseSchemaGenerator, createSchema } from '@raynode/graphql-connector'
import { graphql, GraphQLSchema, printSchema } from 'graphql'
import * as Sequelize from 'sequelize'
import { configuration } from './index'
import { modelMapper } from './model-mapper'
import { typeMapper } from './type-mapper'
import { modelMapper } from './model-mapper'
import { graphql, GraphQLSchema, printSchema } from 'graphql'
import { configuration } from './index'
import { createBaseSchemaGenerator, createSchema } from '@raynode/graphql-connector'
import { models, initialize, uuidv4 } from './tests/sample-models'
import { initialize, models, uuidv4 } from './tests/sample-models'

@@ -125,3 +125,3 @@ describe('model-mapper', () => {

}`)
expect(data.Users.nodes[0].id).toEqual(uuidv4(4))
expect(data.Users.nodes[0].id).toEqual(uuidv4(101))
expect(data).toMatchSnapshot()

@@ -167,2 +167,60 @@ })

})
it('should create a post', async () => {
const { data } = await runQuery(`mutation {
createPost(data: {
title: "new post"
}) {
id
}
}`)
expect(data.createPost.id).toEqual(uuidv4(102))
})
it('should update a post', async () => {
const { data } = await runQuery(`mutation {
updatePost(data: {
title: "This is my new Post"
}, where: {
id: "${uuidv4(102)}"
}) {
id
title
}
}`)
expect(data).toMatchSnapshot()
})
it('should find an updated post', async () => {
const { data } = await runQuery(`{
Post(where: {
id: "${uuidv4(102)}"
}) {
title
}
}`)
expect(data.Post.title).toEqual('This is my new Post')
})
it('should delete the post', async () => {
const { data } = await runQuery(`mutation {
deletePosts(where: {
id: "${uuidv4(102)}"
}) {
title
}
}`)
expect(data.deletePosts[0].title).toEqual('This is my new Post')
})
it('should not find the post', async () => {
const { data } = await runQuery(`{
Post(where: {
id: "${uuidv4(102)}"
}) {
title
}
}`)
expect(data.Post).toBeNull()
})
})
import { AnyModel, createModelMapper, GeneratedModelMapper, Page } from '@raynode/graphql-connector'
import { capitalize } from 'inflection'
import * as Sequelize from 'sequelize'
import { DataTypes } from './type-guards'
import { capitalize } from 'inflection'

@@ -90,15 +90,25 @@ // somehow the sequelize types are really really bad!

return {
const findAll = async (include, where, order?) => {
const nodes = await model.findAll({ include, where, order })
return {
nodes,
page: createPage(0, 100, 0),
}
}
const resolvers = {
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),
}
delete: async (_, { where: { where } }) => {
const deletedItems = await model.findAll({ where })
await model.destroy({ where })
return deletedItems
},
findOne: async () => null,
update: async () => null,
findMany: async (_, { order, where: { where = {}, include = [] } = {} }) => findAll(include, where, order),
findOne: async (_, { order, where: { where = {}, include = [] } = {} }) => model.findOne({ include, where, order }),
update: async (_, { data, where: { where, include } }) => {
await model.update(data, { where })
return model.findAll({ where })
},
}
return resolvers
})

@@ -45,3 +45,3 @@

id,
title: { type: Sequelize.STRING },
title: { type: Sequelize.STRING, allowNull: false },
})

@@ -48,0 +48,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

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