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-e3ced2d.0

44

index.js

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

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

@@ -1092,15 +1096,44 @@ function createEnvelopOrchestrator(plugins) {

const useLazyLoadedSchema = (schemaLoader) => {
let schemaSet$;
return {
onEnveloped({ setSchema, context }) {
setSchema(schemaLoader(context));
const schema$ = schemaLoader(context);
if (isPromise(schema$)) {
schemaSet$ = schema$.then(schemaObj => {
setSchema(schemaObj);
});
}
else {
setSchema(schema$);
}
},
onExecute() {
if (schemaSet$) {
return schemaSet$;
}
return undefined;
},
};
};
const useAsyncSchema = (schemaPromise) => {
const useAsyncSchema = (schema$) => {
let schemaSet$;
return {
onPluginInit({ setSchema }) {
schemaPromise.then(schemaObj => {
setSchema(schemaObj);
});
if (isPromise(schema$)) {
schemaSet$ = schema$.then(schemaObj => {
setSchema(schemaObj);
});
}
else {
setSchema(schema$);
}
},
onContextBuilding() {
return () => {
if (schemaSet$) {
return schemaSet$;
}
return undefined;
};
},
};

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

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

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

2

package.json
{
"name": "@envelop/core",
"version": "2.3.1",
"version": "2.3.2-alpha-e3ced2d.0",
"sideEffects": false,

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

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

@@ -34,1 +34,2 @@ 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