Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@orion-js/resolvers

Package Overview
Dependencies
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orion-js/resolvers - npm Package Compare versions

Comparing version 3.0.7 to 3.0.14

2

lib/resolver/getExecute/getResult.js

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

};
if (options.cache) {
if (options.cache && options.cacheProvider) {
const key = await (0, getCacheKey_1.default)(options, executeOptions);

@@ -22,0 +22,0 @@ const result = await options.cacheProvider.get(key, {

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

export default function (resolverParams: any): {};
import { Schema } from '@orion-js/schema';
export default function (resolverParams: any): Schema;
import { ResolverOptions, Execute } from '../types';
export default function (options: ResolverOptions): Execute<import("../types").Params, any, undefined>;
export default function (options: ResolverOptions): Execute<object, any, undefined>;

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

returns: String,
async resolve(params, viewer) { }
async resolve() { }
});

@@ -24,3 +24,3 @@ expect(typeof resolver).toBe('object');

returns: Number,
async resolve({ value }, viewer) {
async resolve({ value }) {
return value * 2;

@@ -65,3 +65,3 @@ }

returns: Number,
resolve: async (params, viewer) => {
resolve: async (params) => {
return params.value * 2;

@@ -82,7 +82,7 @@ }

returns: Number,
resolve: async function (model, params, viewer) {
resolve: async function (model) {
return model.value * 2;
}
});
resolver.resolve({}, { value: '' });
await resolver.resolve({ value: 1 });
const inModel = resolver.modelResolve;

@@ -106,2 +106,5 @@ });

class TypedParams {
constructor() {
this.value = 1;
}
static getModel() {

@@ -114,3 +117,3 @@ return aModel;

returns: Number,
resolve: async function (item, params, viewer) {
resolve: async function (item, params) {
return params.value * 2;

@@ -137,2 +140,5 @@ }

class Returns {
constructor() {
this.value = 1;
}
static getModel() {

@@ -144,7 +150,7 @@ return aModel;

returns: Returns,
resolve: async (params, viewer) => {
resolve: async () => {
return { value: 2 };
}
});
const result = await resolver.resolve({});
const result = await resolver.resolve();
expect(result.value).toBe(2);

@@ -151,0 +157,0 @@ });

import { OrionCache } from '@orion-js/cache';
export declare type GlobalResolverResolve<ParamsType = any, ReturnType = any> = (params?: ParamsType, viewer?: any) => Promise<ReturnType>;
export declare type ModelResolverResolve<ModelType = any, ParamsType = any, ReturnType = any> = (item: ModelType, params?: ParamsType, viewer?: any) => Promise<ReturnType>;
export declare type GlobalResolverResolve<ParamsType = any, ReturnType = any> = (params: ParamsType, viewer: any) => Promise<ReturnType>;
export declare type ModelResolverResolve<ModelType = any, ParamsType = any, ReturnType = any> = (item: ModelType, params: ParamsType, viewer: any) => Promise<ReturnType>;
export declare type GlobalCheckPermissions = (params: any, viewer: any) => Promise<string>;

@@ -8,11 +8,8 @@ export declare type ModelCheckPermissions = (parent: any, params: any, viewer: any) => Promise<string>;

export declare type ModelGetCacheKey = (parent: any, params: any, viewer: any) => Promise<any>;
export interface Params {
[key: string]: any;
}
export interface ExecuteOptions {
params: Params;
params: object;
viewer: any;
parent?: any;
}
export interface ExecuteParams<ParamsType extends Params = Params, ModelType = undefined> {
export interface ExecuteParams<ParamsType = object, ModelType = undefined> {
params?: ParamsType;

@@ -22,3 +19,3 @@ viewer?: any;

}
export declare type Execute<ParamsType = Params, ReturnType = any, ModelType = undefined> = (executeOptions: ExecuteParams<ParamsType, ModelType>) => Promise<ReturnType>;
export declare type Execute<ParamsType = object, ReturnType = any, ModelType = undefined> = (executeOptions: ExecuteParams<ParamsType, ModelType>) => Promise<ReturnType>;
export interface SharedResolverOptions {

@@ -36,16 +33,13 @@ resolverId?: string;

}
export interface ResolverOptions<ParamsType extends Params = Params, ReturnType = any, ModelType = undefined> extends SharedResolverOptions {
resolve: ModelType extends undefined ? GlobalResolverResolve<ParamsType, ReturnType> : ModelResolverResolve<ModelType, Params, ReturnType>;
export interface ResolverOptions<Resolve = Function> extends SharedResolverOptions {
resolve: Resolve;
}
export interface Resolver<ParamsType = any, ReturnType = any, ModelType = undefined> extends SharedResolverOptions {
execute: Execute<ParamsType, ReturnType, ModelType>;
resolve: ModelType extends undefined ? GlobalResolverResolve<ParamsType, ReturnType> : ModelResolverResolve<ModelType, Params, ReturnType>;
modelResolve?: ModelType extends undefined ? undefined : GlobalResolverResolve<ParamsType, ReturnType>;
declare type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
export interface Resolver<Resolve = Function, ModelType = undefined> extends SharedResolverOptions {
execute: Execute;
resolve: Resolve;
modelResolve: ModelType extends undefined ? undefined : OmitFirstArg<Resolve>;
}
export declare type CreateResolver = <ParamsType, ReturnType>(options: {
resolve: (params?: ParamsType, viewer?: any) => Promise<ReturnType>;
} & ResolverOptions<ParamsType, ReturnType>) => Resolver<ParamsType, ReturnType, undefined>;
export declare type CreateModelResolver = <ModelType, ParamsType, ReturnType>(options: {
resolve: (item: ModelType, params?: ParamsType, viewer?: any) => Promise<ReturnType>;
} & ResolverOptions<ParamsType, ReturnType, ModelType>) => Resolver<ParamsType, ReturnType, ModelType>;
export declare type CreateResolver = <Resolve>(options: ResolverOptions<Resolve>) => Resolver<Resolve>;
export declare type CreateModelResolver = <ModelType, Resolve>(options: ResolverOptions<Resolve>) => Resolver<Resolve, ModelType>;
export interface PermissionCheckerOptions {

@@ -58,1 +52,2 @@ resolver: ResolverOptions;

export declare type PermissionChecker = (options: PermissionCheckerOptions) => Promise<string | void>;
export {};
{
"name": "@orion-js/resolvers",
"version": "3.0.7",
"version": "3.0.14",
"main": "lib/index.js",

@@ -34,3 +34,3 @@ "types": "lib/index.d.ts",

},
"gitHead": "1eb98fb22afbccb18f25b7f895b895b6b68bbfd4"
"gitHead": "265f025c5ed42f9de5f46f4ae9eae3589ec77085"
}
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