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

@graphitation/supermassive

Package Overview
Dependencies
Maintainers
5
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphitation/supermassive - npm Package Compare versions

Comparing version 2.2.3 to 2.3.0

lib/hooks/types.d.ts

10

CHANGELOG.md
# Change Log - @graphitation/supermassive
This log was last generated on Wed, 01 Mar 2023 10:48:32 GMT and should not be manually modified.
This log was last generated on Thu, 30 Mar 2023 08:30:10 GMT and should not be manually modified.
<!-- Start content -->
## 2.3.0
Thu, 30 Mar 2023 08:30:10 GMT
### Minor changes
- [SUPERMASSIVE] Initial execution hooks implementation (sergeystoyan@microsoft.com)
## 2.1.0

@@ -8,0 +16,0 @@

4

lib/executeWithoutSchema.d.ts

@@ -8,2 +8,3 @@ import { GraphQLError } from "graphql";

import { ExecutionWithoutSchemaArgs, FunctionFieldResolver, ResolveInfo, Resolvers, TypeResolver, ExecutionResult } from "./types";
import { ExecutionHooks } from "./hooks/types";
/**

@@ -46,2 +47,3 @@ * Terminology

errors: Array<GraphQLError>;
fieldExecutionHooks?: ExecutionHooks;
}

@@ -78,3 +80,3 @@ /**

[variable: string]: unknown;
}>, operationName: Maybe<string>, fieldResolver: Maybe<FunctionFieldResolver<unknown, unknown>>, typeResolver?: Maybe<TypeResolver<unknown, unknown>>): Array<GraphQLError> | ExecutionContext;
}>, operationName: Maybe<string>, fieldResolver: Maybe<FunctionFieldResolver<unknown, unknown>>, typeResolver?: Maybe<TypeResolver<unknown, unknown>>, fieldExecutionHooks?: ExecutionHooks): Array<GraphQLError> | ExecutionContext;
/**

@@ -81,0 +83,0 @@ * @internal

@@ -45,2 +45,3 @@ "use strict";

var import_values = require("./values");
var import_array = require("./utilities/array");
function executeWithoutSchema(args) {

@@ -56,3 +57,4 @@ const {

fieldResolver,
typeResolver
typeResolver,
fieldExecutionHooks
} = args;

@@ -69,3 +71,4 @@ const combinedResolvers = (0, import_mergeResolvers.mergeResolvers)(resolvers, schemaResolvers);

fieldResolver,
typeResolver
typeResolver,
fieldExecutionHooks
);

@@ -94,3 +97,3 @@ if (!("resolvers" in exeContext)) {

}
function buildExecutionContext(resolvers, document, rootValue, contextValue, rawVariableValues, operationName, fieldResolver, typeResolver) {
function buildExecutionContext(resolvers, document, rootValue, contextValue, rawVariableValues, operationName, fieldResolver, typeResolver, fieldExecutionHooks) {
var _a, _b;

@@ -145,3 +148,4 @@ let operation;

typeResolver: typeResolver != null ? typeResolver : defaultTypeResolver,
errors: []
errors: [],
fieldExecutionHooks
};

@@ -228,2 +232,3 @@ }

const fieldName = fieldNodes[0].name.value;
const hooks = exeContext.fieldExecutionHooks;
let resolveFn;

@@ -251,2 +256,3 @@ let returnTypeName;

}
const isDefaultResolverUsed = !resolveFn;
if (!resolveFn) {

@@ -270,2 +276,5 @@ resolveFn = exeContext.fieldResolver;

);
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.beforeFieldResolve)) {
invokeBeforeFieldResolveHook(info, exeContext);
}
const contextValue = exeContext.contextValue;

@@ -276,12 +285,26 @@ const result = resolveFn(source, args, contextValue, info);

completed = result.then(
(resolved) => completeValue(
exeContext,
returnTypeNode,
fieldNodes,
info,
path,
resolved
)
(resolved) => {
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve)) {
invokeAfterFieldResolveHook(info, exeContext, resolved);
}
return completeValue(
exeContext,
returnTypeNode,
fieldNodes,
info,
path,
resolved
);
},
(rawError) => {
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve)) {
invokeAfterFieldResolveHook(info, exeContext, void 0, rawError);
}
throw rawError;
}
);
} else {
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve)) {
invokeAfterFieldResolveHook(info, exeContext, result);
}
completed = completeValue(

@@ -297,18 +320,39 @@ exeContext,

if ((0, import_isPromise.isPromise)(completed)) {
return completed.then(void 0, (rawError) => {
const error = (0, import_graphql.locatedError)(
rawError,
fieldNodes,
(0, import_Path.pathToArray)(path)
);
return handleFieldError(error, returnTypeNode, exeContext);
});
return completed.then(
(resolved) => {
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
invokeAfterFieldCompleteHook(info, exeContext, resolved);
}
return resolved;
},
(rawError) => {
const error = (0, import_graphql.locatedError)(
rawError,
fieldNodes,
(0, import_Path.pathToArray)(path)
);
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
invokeAfterFieldCompleteHook(info, exeContext, void 0, error);
}
return handleFieldError(error, returnTypeNode, exeContext);
}
);
}
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
invokeAfterFieldCompleteHook(info, exeContext, completed);
}
return completed;
} catch (rawError) {
const pathArray = (0, import_Path.pathToArray)(path);
const error = (0, import_graphql.locatedError)(
rawError,
fieldNodes,
(0, import_Path.pathToArray)(path)
pathArray
);
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve) && error.path && (0, import_array.arraysAreEqual)(pathArray, error.path)) {
invokeAfterFieldResolveHook(info, exeContext, void 0, error);
}
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
invokeAfterFieldCompleteHook(info, exeContext, void 0, error);
}
return handleFieldError(error, returnTypeNode, exeContext);

@@ -564,2 +608,86 @@ }

}
function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
var _a;
const hook = (_a = exeContext.fieldExecutionHooks) == null ? void 0 : _a.beforeFieldResolve;
if (!hook) {
return;
}
executeSafe(
() => hook({
resolveInfo,
context: exeContext.contextValue
}),
(_, rawError) => {
const error = toGraphQLError(
rawError,
resolveInfo.path,
"Unexpected error in beforeFieldResolve hook"
);
exeContext.errors.push(error);
}
);
}
function invokeAfterFieldResolveHook(resolveInfo, exeContext, result, error) {
var _a;
const hook = (_a = exeContext.fieldExecutionHooks) == null ? void 0 : _a.afterFieldResolve;
if (!hook) {
return;
}
executeSafe(
() => hook({
resolveInfo,
context: exeContext.contextValue,
result,
error
}),
(_, rawError) => {
const error2 = toGraphQLError(
rawError,
resolveInfo.path,
"Unexpected error in afterFieldResolve hook"
);
exeContext.errors.push(error2);
}
);
}
function invokeAfterFieldCompleteHook(resolveInfo, exeContext, result, error) {
var _a;
const hook = (_a = exeContext.fieldExecutionHooks) == null ? void 0 : _a.afterFieldComplete;
if (!hook) {
return;
}
executeSafe(
() => hook({
resolveInfo,
context: exeContext.contextValue,
result,
error
}),
(_, rawError) => {
const error2 = toGraphQLError(
rawError,
resolveInfo.path,
"Unexpected error in afterFieldComplete hook"
);
exeContext.errors.push(error2);
}
);
}
function executeSafe(execute, onComplete) {
let error;
let result;
try {
result = execute();
} catch (e) {
error = e;
} finally {
onComplete(result, error);
return result;
}
}
function toGraphQLError(originalError, path, prependMessage) {
const originalMessage = originalError instanceof Error ? originalError.message : (0, import_inspect.inspect)(originalError);
const error = new Error(`${prependMessage}: ${originalMessage}`);
return (0, import_graphql.locatedError)(error, void 0, (0, import_Path.pathToArray)(path));
}
const defaultTypeResolver = function(value) {

@@ -566,0 +694,0 @@ if ((0, import_isObjectLike.isObjectLike)(value) && typeof value.__typename === "string") {

import { PromiseOrValue } from "./jsutils/PromiseOrValue";
import { ExecutionResult, ExecutionWithSchemaArgs } from "./types";
export declare function executeWithSchema({ typeDefs, resolvers, document: rawDocument, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver, }: ExecutionWithSchemaArgs): PromiseOrValue<ExecutionResult>;
export declare function executeWithSchema({ typeDefs, resolvers, document: rawDocument, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver, fieldExecutionHooks, }: ExecutionWithSchemaArgs): PromiseOrValue<ExecutionResult>;
//# sourceMappingURL=executeWithSchema.d.ts.map

@@ -35,3 +35,4 @@ "use strict";

fieldResolver,
typeResolver
typeResolver,
fieldExecutionHooks
}) {

@@ -59,4 +60,5 @@ const schema = (0, import_graphql.buildASTSchema)(typeDefs);

fieldResolver,
typeResolver
typeResolver,
fieldExecutionHooks
});
}

@@ -12,2 +12,3 @@ export { executeWithoutSchema } from "./executeWithoutSchema";

export type { NameNode, DocumentNode, OperationDefinitionNode, VariableDefinitionNode, VariableNode, SelectionSetNode, FieldNode, ArgumentNode, FragmentSpreadNode, InlineFragmentNode, FragmentDefinitionNode, IntValueNode, FloatValueNode, StringValueNode, BooleanValueNode, NullValueNode, EnumValueNode, ListValueNode, ObjectValueNode, ObjectFieldNode, DirectiveNode, NamedTypeNode, ListTypeNode, NonNullTypeNode, SchemaDefinitionNode, OperationTypeDefinitionNode, ScalarTypeDefinitionNode, ObjectTypeDefinitionNode, FieldDefinitionNode, InputValueDefinitionNode, InterfaceTypeDefinitionNode, UnionTypeDefinitionNode, EnumTypeDefinitionNode, EnumValueDefinitionNode, InputObjectTypeDefinitionNode, DirectiveDefinitionNode, SchemaExtensionNode, ScalarTypeExtensionNode, ObjectTypeExtensionNode, InterfaceTypeExtensionNode, UnionTypeExtensionNode, EnumTypeExtensionNode, InputObjectTypeExtensionNode, } from "./ast/TypedAST";
export { BeforeFieldResolveHookArgs, AfterFieldResolveHookArgs, AfterFieldCompleteHookArgs, BeforeFieldResolveHook, AfterFieldResolveHook, AfterFieldCompleteHook, ExecutionHooks, } from "./hooks/types";
//# sourceMappingURL=index.d.ts.map

@@ -21,2 +21,9 @@ "use strict";

__export(src_exports, {
AfterFieldCompleteHook: () => import_types.AfterFieldCompleteHook,
AfterFieldCompleteHookArgs: () => import_types.AfterFieldCompleteHookArgs,
AfterFieldResolveHook: () => import_types.AfterFieldResolveHook,
AfterFieldResolveHookArgs: () => import_types.AfterFieldResolveHookArgs,
BeforeFieldResolveHook: () => import_types.BeforeFieldResolveHook,
BeforeFieldResolveHookArgs: () => import_types.BeforeFieldResolveHookArgs,
ExecutionHooks: () => import_types.ExecutionHooks,
addTypesToRequestDocument: () => import_addTypesToRequestDocument.addTypesToRequestDocument,

@@ -40,1 +47,2 @@ annotateDocumentGraphQLTransform: () => import_annotateDocumentGraphQLTransform.annotateDocumentGraphQLTransform,

var import_annotateDocumentGraphQLTransform = require("./transforms/annotateDocumentGraphQLTransform");
var import_types = require("./hooks/types");

@@ -7,2 +7,3 @@ import { GraphQLEnumType, GraphQLError, GraphQLFormattedError, GraphQLInputObjectType, GraphQLScalarType, DocumentNode as UntypedDocumentNode } from "graphql";

import { Path } from "./jsutils/Path";
import { ExecutionHooks } from "./hooks/types";
export declare type ScalarTypeResolver = GraphQLScalarType;

@@ -84,2 +85,3 @@ export declare type EnumTypeResolver = GraphQLEnumType;

subscribeFieldResolver?: Maybe<FunctionFieldResolver<any, any>>;
fieldExecutionHooks?: ExecutionHooks;
}

@@ -86,0 +88,0 @@ export declare type ExecutionWithoutSchemaArgs = CommonExecutionArgs & {

{
"name": "@graphitation/supermassive",
"license": "MIT",
"version": "2.2.3",
"version": "2.3.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

Sorry, the diff of this file is not supported yet

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