@envelop/core 1.4.0-alpha-d43fe1a.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -9
- package/index.mjs +1 -9
- package/orchestrator.d.ts +2 -1
- package/package.json +3 -3
- package/utils.d.ts +6 -5
package/index.js
CHANGED
|
@@ -417,8 +417,6 @@ function createEnvelopOrchestrator(plugins) {
|
|
|
417
417
|
let result = await subscribeFn({
|
|
418
418
|
...args,
|
|
419
419
|
contextValue: context,
|
|
420
|
-
// Casted for GraphQL.js 15 compatibility
|
|
421
|
-
// Can be removed once we drop support for GraphQL.js 15
|
|
422
420
|
});
|
|
423
421
|
const onNextHandler = [];
|
|
424
422
|
const onEndHandler = [];
|
|
@@ -527,7 +525,7 @@ function createEnvelopOrchestrator(plugins) {
|
|
|
527
525
|
const onNextHandler = [];
|
|
528
526
|
const onEndHandler = [];
|
|
529
527
|
for (const afterCb of afterCalls) {
|
|
530
|
-
const hookResult = afterCb({
|
|
528
|
+
const hookResult = await afterCb({
|
|
531
529
|
args: args,
|
|
532
530
|
result,
|
|
533
531
|
setResult: newResult => {
|
|
@@ -656,16 +654,12 @@ function traceOrchestrator(orchestrator) {
|
|
|
656
654
|
typeResolver,
|
|
657
655
|
}
|
|
658
656
|
: argsOrSchema;
|
|
659
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
660
|
-
// @ts-ignore GraphQL.js types contextValue as unknown
|
|
661
657
|
const done = createTracer('execute', args.contextValue || {});
|
|
662
658
|
try {
|
|
663
659
|
const result = await orchestrator.execute(args);
|
|
664
660
|
done();
|
|
665
661
|
if (!types.isAsyncIterable(result)) {
|
|
666
662
|
result.extensions = result.extensions || {};
|
|
667
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
668
|
-
// @ts-ignore GraphQL.js types contextValue as unknown
|
|
669
663
|
result.extensions.envelopTracing = args.contextValue._envelopTracing;
|
|
670
664
|
}
|
|
671
665
|
else {
|
|
@@ -692,8 +686,6 @@ function traceOrchestrator(orchestrator) {
|
|
|
692
686
|
subscribeFieldResolver,
|
|
693
687
|
}
|
|
694
688
|
: argsOrSchema;
|
|
695
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
696
|
-
// @ts-ignore GraphQL.js types contextValue as unknown
|
|
697
689
|
const done = createTracer('subscribe', args.contextValue || {});
|
|
698
690
|
try {
|
|
699
691
|
return await orchestrator.subscribe(args);
|
package/index.mjs
CHANGED
|
@@ -414,8 +414,6 @@ function createEnvelopOrchestrator(plugins) {
|
|
|
414
414
|
let result = await subscribeFn({
|
|
415
415
|
...args,
|
|
416
416
|
contextValue: context,
|
|
417
|
-
// Casted for GraphQL.js 15 compatibility
|
|
418
|
-
// Can be removed once we drop support for GraphQL.js 15
|
|
419
417
|
});
|
|
420
418
|
const onNextHandler = [];
|
|
421
419
|
const onEndHandler = [];
|
|
@@ -524,7 +522,7 @@ function createEnvelopOrchestrator(plugins) {
|
|
|
524
522
|
const onNextHandler = [];
|
|
525
523
|
const onEndHandler = [];
|
|
526
524
|
for (const afterCb of afterCalls) {
|
|
527
|
-
const hookResult = afterCb({
|
|
525
|
+
const hookResult = await afterCb({
|
|
528
526
|
args: args,
|
|
529
527
|
result,
|
|
530
528
|
setResult: newResult => {
|
|
@@ -653,16 +651,12 @@ function traceOrchestrator(orchestrator) {
|
|
|
653
651
|
typeResolver,
|
|
654
652
|
}
|
|
655
653
|
: argsOrSchema;
|
|
656
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
657
|
-
// @ts-ignore GraphQL.js types contextValue as unknown
|
|
658
654
|
const done = createTracer('execute', args.contextValue || {});
|
|
659
655
|
try {
|
|
660
656
|
const result = await orchestrator.execute(args);
|
|
661
657
|
done();
|
|
662
658
|
if (!isAsyncIterable(result)) {
|
|
663
659
|
result.extensions = result.extensions || {};
|
|
664
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
665
|
-
// @ts-ignore GraphQL.js types contextValue as unknown
|
|
666
660
|
result.extensions.envelopTracing = args.contextValue._envelopTracing;
|
|
667
661
|
}
|
|
668
662
|
else {
|
|
@@ -689,8 +683,6 @@ function traceOrchestrator(orchestrator) {
|
|
|
689
683
|
subscribeFieldResolver,
|
|
690
684
|
}
|
|
691
685
|
: argsOrSchema;
|
|
692
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
693
|
-
// @ts-ignore GraphQL.js types contextValue as unknown
|
|
694
686
|
const done = createTracer('subscribe', args.contextValue || {});
|
|
695
687
|
try {
|
|
696
688
|
return await orchestrator.subscribe(args);
|
package/orchestrator.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ArbitraryObject, EnvelopContextFnWrapper, GetEnvelopedFn, Plugin, DefaultContext
|
|
1
|
+
import { ArbitraryObject, EnvelopContextFnWrapper, GetEnvelopedFn, Plugin, DefaultContext } from '@envelop/types';
|
|
2
2
|
import { GraphQLSchema } from 'graphql';
|
|
3
|
+
import { Maybe } from 'graphql/jsutils/Maybe';
|
|
3
4
|
export declare type EnvelopOrchestrator<InitialContext extends ArbitraryObject = ArbitraryObject, PluginsContext extends ArbitraryObject = ArbitraryObject> = {
|
|
4
5
|
init: (initialContext?: Maybe<InitialContext>) => void;
|
|
5
6
|
parse: EnvelopContextFnWrapper<ReturnType<GetEnvelopedFn<PluginsContext>>['parse'], InitialContext>;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/core",
|
|
3
|
-
"version": "1.4.0
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"graphql": "^14.0.0 || ^15.0.0
|
|
6
|
+
"graphql": "^14.0.0 || ^15.0.0"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@envelop/types": "1.3.0
|
|
9
|
+
"@envelop/types": "1.3.0"
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
package/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ASTNode, DocumentNode, OperationDefinitionNode, Source, ExecutionResult, SubscriptionArgs, ExecutionArgs } from 'graphql';
|
|
2
|
-
import { AsyncIterableIteratorOrValue, ExecuteFunction, SubscribeFunction
|
|
2
|
+
import { AsyncIterableIteratorOrValue, ExecuteFunction, SubscribeFunction } from '@envelop/types';
|
|
3
|
+
import { PromiseOrValue } from 'graphql/jsutils/PromiseOrValue';
|
|
3
4
|
export declare const envelopIsIntrospectionSymbol: unique symbol;
|
|
4
5
|
export declare function isOperationDefinition(def: ASTNode): def is OperationDefinitionNode;
|
|
5
6
|
export declare function isIntrospectionOperation(operation: OperationDefinitionNode): boolean;
|
|
@@ -8,11 +9,11 @@ export declare function isIntrospectionOperationString(operation: string | Sourc
|
|
|
8
9
|
/**
|
|
9
10
|
* Utility function for making a subscribe function that handles polymorphic arguments.
|
|
10
11
|
*/
|
|
11
|
-
export declare const makeSubscribe: (subscribeFn: (args: SubscriptionArgs) => PromiseOrValue<AsyncIterableIterator<ExecutionResult
|
|
12
|
-
export declare function mapAsyncIterator<TInput, TOutput = TInput>(asyncIterable:
|
|
12
|
+
export declare const makeSubscribe: (subscribeFn: (args: SubscriptionArgs) => PromiseOrValue<AsyncIterableIterator<ExecutionResult> | ExecutionResult>) => SubscribeFunction;
|
|
13
|
+
export declare function mapAsyncIterator<TInput, TOutput = TInput>(asyncIterable: AsyncIterableIterator<TInput>, map: (input: TInput) => Promise<TOutput> | TOutput): AsyncIterableIterator<TOutput>;
|
|
13
14
|
/**
|
|
14
15
|
* Utility function for making a execute function that handles polymorphic arguments.
|
|
15
16
|
*/
|
|
16
17
|
export declare const makeExecute: (executeFn: (args: ExecutionArgs) => PromiseOrValue<AsyncIterableIteratorOrValue<ExecutionResult>>) => ExecuteFunction;
|
|
17
|
-
export declare function finalAsyncIterator<TInput>(asyncIterable:
|
|
18
|
-
export declare function errorAsyncIterator<TInput>(asyncIterable:
|
|
18
|
+
export declare function finalAsyncIterator<TInput>(asyncIterable: AsyncIterableIterator<TInput>, onFinal: () => void): AsyncIterableIterator<TInput>;
|
|
19
|
+
export declare function errorAsyncIterator<TInput>(asyncIterable: AsyncIterableIterator<TInput>, onError: (err: unknown) => void): AsyncIterableIterator<TInput>;
|