@orion-js/resolvers
Advanced tools
Comparing version 3.0.0 to 3.0.6
@@ -12,2 +12,3 @@ "use strict"; | ||
const cleanReturns_1 = __importDefault(require("./cleanReturns")); | ||
const getArgs_1 = require("./getArgs"); | ||
const createResolver = function (options) { | ||
@@ -22,7 +23,12 @@ options.params = (0, cleanParams_1.default)(options.params); | ||
} | ||
const resolve = options.resolve; | ||
const execute = (0, getExecute_1.default)(options); | ||
const resolve = async (...args) => { | ||
let { parent, params, viewer } = (0, getArgs_1.getArgs)(...args); | ||
const executeOptions = { parent, params, viewer }; | ||
return await execute(executeOptions); | ||
}; | ||
const resolver = { | ||
...options, | ||
resolve, | ||
execute: (0, getExecute_1.default)(options) | ||
execute | ||
}; | ||
@@ -29,0 +35,0 @@ return resolver; |
@@ -11,2 +11,3 @@ "use strict"; | ||
expect(typeof resolver).toBe('object'); | ||
expect(typeof resolver.resolve).toBe('function'); | ||
expect(typeof resolver.execute).toBe('function'); | ||
@@ -96,2 +97,5 @@ expect(typeof resolver.resolverId).toBe('string'); | ||
}; | ||
}, | ||
initItem(item) { | ||
return item; | ||
} | ||
@@ -123,2 +127,5 @@ }; | ||
}; | ||
}, | ||
initItem(item) { | ||
return item; | ||
} | ||
@@ -148,1 +155,15 @@ }; | ||
}); | ||
it('should allow calling resolver.resolve', async () => { | ||
const resolver = (0, index_1.resolver)({ | ||
resolve: async ({ title }) => { | ||
return `${title}`; | ||
} | ||
}); | ||
const modelResolver = (0, index_1.modelResolver)({ | ||
resolve: async ({ title }) => { | ||
return `${title}`; | ||
} | ||
}); | ||
expect(await resolver.resolve({ title: 'test' })).toBe('test'); | ||
expect(await modelResolver.resolve({ title: 'test' })).toBe('test'); | ||
}); |
{ | ||
"name": "@orion-js/resolvers", | ||
"version": "3.0.0", | ||
"version": "3.0.6", | ||
"main": "lib/index.js", | ||
@@ -34,3 +34,3 @@ "types": "lib/index.d.ts", | ||
}, | ||
"gitHead": "27bda585ffc16d92c70c958227605f3b61171c64" | ||
"gitHead": "91b207f9f7afa418177b5aeace2e5f9b0a0ef04d" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26363
34
661