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

@envelop/core

Package Overview
Dependencies
Maintainers
1
Versions
1491
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@envelop/core - npm Package Compare versions

Comparing version

to
2.3.2-alpha-763ffe6.0

77

index.js

@@ -302,6 +302,2 @@ 'use strict';

}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
function isPromise(obj) {
return obj != null && obj.then;
}

@@ -1095,78 +1091,16 @@ function createEnvelopOrchestrator(plugins) {

};
const VALIDATE_FN = Symbol('VALIDATE_FN');
const useLazyLoadedSchema = (schemaLoader) => {
let schemaSet$;
return {
onEnveloped({ setSchema, context }) {
const schema$ = schemaLoader(context);
if (isPromise(schema$)) {
schemaSet$ = schema$.then(schemaObj => {
setSchema(schemaObj);
});
}
else {
setSchema(schema$);
}
setSchema(schemaLoader(context));
},
onValidate({ validateFn, setValidationFn, extendContext }) {
if (schemaSet$) {
extendContext({
[VALIDATE_FN]: validateFn,
});
setValidationFn(() => []);
}
},
onExecute({ args: { schema, document, contextValue }, setResultAndStopExecution }) {
if (schemaSet$) {
const validateFn = contextValue[VALIDATE_FN];
const errors = validateFn(schema, document);
if (errors === null || errors === void 0 ? void 0 : errors.length) {
setResultAndStopExecution({
errors,
});
}
else {
return schemaSet$;
}
}
return undefined;
},
};
};
const useAsyncSchema = (schema$) => {
let schemaSet$;
const useAsyncSchema = (schemaPromise) => {
return {
onPluginInit({ setSchema }) {
if (isPromise(schema$)) {
schemaSet$ = schema$.then(schemaObj => {
setSchema(schemaObj);
});
}
else {
setSchema(schema$);
}
schemaPromise.then(schemaObj => {
setSchema(schemaObj);
});
},
onValidate({ validateFn, setValidationFn, extendContext }) {
if (schemaSet$) {
extendContext({
[VALIDATE_FN]: validateFn,
});
setValidationFn(() => []);
}
},
onExecute({ args: { schema, document, contextValue }, setResultAndStopExecution }) {
if (schemaSet$) {
const validateFn = contextValue[VALIDATE_FN];
const errors = validateFn(schema, document);
if (errors === null || errors === void 0 ? void 0 : errors.length) {
setResultAndStopExecution({
errors,
});
}
else {
return schemaSet$;
}
}
return undefined;
},
};

@@ -1367,3 +1301,2 @@ };

exports.isPluginEnabled = isPluginEnabled;
exports.isPromise = isPromise;
exports.makeExecute = makeExecute;

@@ -1370,0 +1303,0 @@ exports.makeSubscribe = makeSubscribe;

2

package.json
{
"name": "@envelop/core",
"version": "2.3.2-alpha-3ace273.0",
"version": "2.3.2-alpha-763ffe6.0",
"sideEffects": false,

@@ -5,0 +5,0 @@ "peerDependencies": {

import { Plugin } from '@envelop/types';
import { GraphQLError } from 'graphql';
import { GraphQLError, GraphQLErrorExtensions } from 'graphql';
export declare const DEFAULT_ERROR_MESSAGE = "Unexpected error.";
export declare class EnvelopError extends GraphQLError {
constructor(message: string, extensions?: Record<string, any>);
constructor(message: string, extensions?: GraphQLErrorExtensions);
}

@@ -7,0 +7,0 @@ export declare type FormatErrorHandler = (error: GraphQLError | unknown, message: string, isDev: boolean) => GraphQLError;

import { GraphQLSchema } from 'graphql';
import { DefaultContext, Maybe, Plugin, PromiseOrValue } from '@envelop/types';
import { DefaultContext, Maybe, Plugin } from '@envelop/types';
export declare const useSchema: (schema: GraphQLSchema) => Plugin;
export declare const useLazyLoadedSchema: (schemaLoader: (context: Maybe<DefaultContext>) => PromiseOrValue<GraphQLSchema>) => Plugin;
export declare const useAsyncSchema: (schema$: PromiseOrValue<GraphQLSchema>) => Plugin;
export declare const useLazyLoadedSchema: (schemaLoader: (context: Maybe<DefaultContext>) => GraphQLSchema) => Plugin;
export declare const useAsyncSchema: (schemaPromise: Promise<GraphQLSchema>) => Plugin;

@@ -34,2 +34,1 @@ import { ASTNode, DocumentNode, OperationDefinitionNode, Source, ExecutionResult, SubscriptionArgs, ExecutionArgs } from 'graphql';

export declare function errorAsyncIterator<TInput>(source: AsyncIterable<TInput>, onError: (err: unknown) => void): AsyncGenerator<TInput>;
export declare function isPromise<T>(obj: any): obj is Promise<T>;

Sorry, the diff of this file is not supported yet