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

db2graphql

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

db2graphql - npm Package Compare versions

Comparing version 0.3.7 to 0.3.8

2

package.json
{
"name": "db2graphql",
"version": "0.3.7",
"version": "0.3.8",
"description": "Generate Graphql schema based on existing relational database",

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

@@ -74,9 +74,10 @@ const PostgreSQL = require('../src/adapters/postgres');

/**
* Set authorization callback
* Set before hook
*
* @param {Function} validator
* @param {Function} validator The validator callback. Must return true/false
* @param {Function} rejected The rejected callback. Must return resolver type/null
*/
isAuthorized(validator, rejected) {
this.resolver.isAuthorizedHook.validator = validator
if (rejected) this.resolver.isAuthorizedHook.rejected = rejected;
onBefore(validator, rejected) {
this.resolver.beforeHook.validator = validator
if (rejected) this.resolver.beforeHook.rejected = rejected;
}

@@ -83,0 +84,0 @@

@@ -29,4 +29,4 @@ const utils = require('../utils/utils');

// Default authorization hook
this.isAuthorizedHook = {
// Default before hook
this.beforeHook = {
validator: async () => true,

@@ -154,4 +154,4 @@ rejected: async () => null

this.resolvers[namespace][name] = async (root = null, args = {}, context = {}) => {
const isAuthorized = await this.isAuthorizedHook.validator(namespace, name, root, args, context);
if (!isAuthorized) return await this.isAuthorizedHook.rejected(namespace, name, root, args, context);
const passBefore = await this.beforeHook.validator(namespace, name, root, args, context);
if (!passBefore) return await this.beforeHook.rejected(namespace, name, root, args, context);
const db = this.dbDriver ? this.dbDriver.db : null;

@@ -158,0 +158,0 @@ context.ioc = { resolver: this, db };

@@ -269,3 +269,3 @@ const db2g = require('../src/db2g');

test('it should set and pass authorization hook', async (done) => {
test('it should set and pass before hook', async (done) => {
const api = new db2g();

@@ -277,3 +277,3 @@ const validator = async (type, field, parent, args) => {

}
api.isAuthorized(validator)
api.onBefore(validator)
api.add('Mutation', 'putFoo', 'Foo', (root, args, context) => {

@@ -286,6 +286,6 @@ done();

test('it should set and get denied in authorization hook', async (done) => {
test('it should set and get denied on before hook', async (done) => {
const api = new db2g();
const validator = async () => false;
api.isAuthorized(validator);
api.onBefore(validator);
api.add('Mutation', 'putFoo', 'Foo', () => {});

@@ -298,3 +298,3 @@ const resolvers = api.getResolvers();

test('it should set and get rejected in authorization hook', async (done) => {
test('it should set and get rejected on before hook', async (done) => {
const api = new db2g();

@@ -311,3 +311,3 @@ const validator = async (type, field, parent, args) => {

}
api.isAuthorized(validator, rejected)
api.onBefore(validator, rejected)
api.add('Mutation', 'putFoo', 'Foo', () => {});

@@ -314,0 +314,0 @@ const resolvers = api.getResolvers();

@@ -254,5 +254,5 @@ const Resolver = require('../../src/graphql/resolver');

test('it should get denied on default authorization hook', async (done) => {
test('it should get denied on default before hook', async (done) => {
const resolver = new Resolver();
resolver.isAuthorizedHook.validator = async () => false;
resolver.beforeHook.validator = async () => false;
const callback = async () => {}

@@ -259,0 +259,0 @@ resolver.add('Query', 'getPage', 'foo', callback);

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