@graphitation/supermassive
Advanced tools
Comparing version 3.6.4 to 3.7.0
# Change Log - @graphitation/supermassive | ||
<!-- This log was last generated on Wed, 30 Oct 2024 12:58:08 GMT and should not be manually modified. --> | ||
<!-- This log was last generated on Wed, 06 Nov 2024 13:29:02 GMT and should not be manually modified. --> | ||
<!-- Start content --> | ||
## 3.7.0 | ||
Wed, 06 Nov 2024 13:29:02 GMT | ||
### Minor changes | ||
- async before hooks added (77059398+vejrj@users.noreply.github.com) | ||
## 3.6.4 | ||
Wed, 30 Oct 2024 12:58:08 GMT | ||
Wed, 30 Oct 2024 12:58:29 GMT | ||
@@ -11,0 +19,0 @@ ### Patches |
@@ -106,3 +106,3 @@ "use strict"; | ||
} else { | ||
return executeOperation(exeContext); | ||
return executeOperationWithBeforeHook(exeContext); | ||
} | ||
@@ -199,2 +199,13 @@ } | ||
} | ||
function executeOperationWithBeforeHook(exeContext) { | ||
const hooks = exeContext.fieldExecutionHooks; | ||
let hook; | ||
if (hooks == null ? void 0 : hooks.beforeOperationExecute) { | ||
hook = invokeBeforeOperationExecuteHook(exeContext); | ||
} | ||
if ((0, import_isPromise.isPromise)(hook)) { | ||
return hook.then(() => executeOperation(exeContext)); | ||
} | ||
return executeOperation(exeContext); | ||
} | ||
function executeOperation(exeContext) { | ||
@@ -210,6 +221,2 @@ try { | ||
let result; | ||
const hooks = exeContext.fieldExecutionHooks; | ||
if (hooks == null ? void 0 : hooks.beforeOperationExecute) { | ||
invokeBeforeOperationExecuteHook(exeContext); | ||
} | ||
switch (operation.operation) { | ||
@@ -482,3 +489,6 @@ case "query": | ||
} | ||
const result = resolveFn(rootValue, args, contextValue, info); | ||
const result = (0, import_isPromise.isPromise)(hookContext) ? hookContext.then((context) => { | ||
hookContext = context; | ||
return resolveFn(rootValue, args, contextValue, info); | ||
}) : resolveFn(rootValue, args, contextValue, info); | ||
if ((0, import_isPromise.isPromise)(result)) { | ||
@@ -567,7 +577,20 @@ return result.then(assertEventStream).then( | ||
const hooks = exeContext == null ? void 0 : exeContext.fieldExecutionHooks; | ||
let beforeExecuteFieldsHook; | ||
if (hooks == null ? void 0 : hooks.beforeSubscriptionEventEmit) { | ||
invokeBeforeSubscriptionEventEmitHook(perEventContext, payload); | ||
beforeExecuteFieldsHook = invokeBeforeSubscriptionEventEmitHook( | ||
perEventContext, | ||
payload | ||
); | ||
} | ||
try { | ||
const data = executeFields( | ||
const data = (0, import_isPromise.isPromise)(beforeExecuteFieldsHook) ? beforeExecuteFieldsHook.then( | ||
() => executeFields( | ||
exeContext, | ||
parentTypeName, | ||
payload, | ||
path, | ||
groupedFieldSet, | ||
void 0 | ||
) | ||
) : executeFields( | ||
exeContext, | ||
@@ -638,3 +661,6 @@ parentTypeName, | ||
} | ||
const result = resolveFn(source, args, contextValue, info); | ||
const result = (0, import_isPromise.isPromise)(hookContext) ? hookContext.then((context) => { | ||
hookContext = context; | ||
return resolveFn(source, args, contextValue, info); | ||
}) : resolveFn(source, args, contextValue, info); | ||
let completed; | ||
@@ -1380,5 +1406,16 @@ if ((0, import_isPromise.isPromise)(result)) { | ||
} finally { | ||
onComplete(result, error); | ||
if (!(0, import_isPromise.isPromise)(result)) { | ||
onComplete(result, error); | ||
} | ||
} | ||
return result; | ||
if (!(0, import_isPromise.isPromise)(result)) { | ||
return result; | ||
} | ||
return result.then((hookResult) => { | ||
onComplete(hookResult, error); | ||
return hookResult; | ||
}).catch((e) => { | ||
onComplete(void 0, e); | ||
return void 0; | ||
}); | ||
} | ||
@@ -1385,0 +1422,0 @@ function toGraphQLError(originalError, path, prependMessage) { |
@@ -30,3 +30,3 @@ import type { OperationDefinitionNode } from "graphql"; | ||
export interface BeforeFieldResolveHook<ResolveContext = unknown, BeforeHookContext = unknown> { | ||
(args: BaseExecuteFieldHookArgs<ResolveContext>): BeforeHookContext; | ||
(args: BaseExecuteFieldHookArgs<ResolveContext>): Promise<BeforeHookContext> | BeforeHookContext; | ||
} | ||
@@ -43,6 +43,6 @@ export interface AfterFieldResolveHook<ResolveContext = unknown, BeforeHookContext = unknown, AfterHookContext = BeforeHookContext> { | ||
export interface BeforeOperationExecuteHook<ResolveContext = unknown> { | ||
(args: BaseExecuteOperationHookArgs<ResolveContext>): void; | ||
(args: BaseExecuteOperationHookArgs<ResolveContext>): void | Promise<void>; | ||
} | ||
export interface BeforeSubscriptionEventEmitHook<ResolveContext = unknown> { | ||
(args: BeforeSubscriptionEventEmitHookArgs<ResolveContext>): void; | ||
(args: BeforeSubscriptionEventEmitHookArgs<ResolveContext>): void | Promise<void>; | ||
} | ||
@@ -49,0 +49,0 @@ export interface ExecutionHooks<ResolveContext = unknown, BeforeHookContext = unknown, AfterHookContext = BeforeHookContext> { |
{ | ||
"name": "@graphitation/supermassive", | ||
"license": "MIT", | ||
"version": "3.6.4", | ||
"version": "3.7.0", | ||
"main": "./lib/index", | ||
@@ -6,0 +6,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1620569
16223