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

@graphitation/supermassive

Package Overview
Dependencies
Maintainers
4
Versions
112
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 0.7.2 to 0.8.0

17

CHANGELOG.json

@@ -5,3 +5,18 @@ {

{
"date": "Mon, 07 Feb 2022 09:13:32 GMT",
"date": "Thu, 10 Feb 2022 13:09:41 GMT",
"tag": "@graphitation/supermassive_v0.8.0",
"version": "0.8.0",
"comments": {
"minor": [
{
"author": "jakubvejr@microsoft.com",
"package": "@graphitation/supermassive",
"commit": "a12b07ea264c714c3a1a4594084cfe9145e0a3a8",
"comment": "Resolvers merge is not required before using executeWithoutSchema"
}
]
}
},
{
"date": "Mon, 07 Feb 2022 09:13:38 GMT",
"tag": "@graphitation/supermassive_v0.7.2",

@@ -8,0 +23,0 @@ "version": "0.7.2",

# Change Log - @graphitation/supermassive
This log was last generated on Mon, 07 Feb 2022 09:13:32 GMT and should not be manually modified.
This log was last generated on Thu, 10 Feb 2022 13:09:41 GMT and should not be manually modified.
<!-- Start content -->
## 0.8.0
Thu, 10 Feb 2022 13:09:41 GMT
### Minor changes
- Resolvers merge is not required before using executeWithoutSchema (jakubvejr@microsoft.com)
## 0.7.2
Mon, 07 Feb 2022 09:13:32 GMT
Mon, 07 Feb 2022 09:13:38 GMT

@@ -11,0 +19,0 @@ ### Patches

@@ -49,2 +49,4 @@ var __create = Object.create;

var import_addTypesToRequestDocument = __toModule(require("../ast/addTypesToRequestDocument"));
var import_extractImplicitTypesRuntime = __toModule(require("../extractImplicitTypesRuntime"));
var import_values = __toModule(require("../values"));
const query = import_fs.default.readFileSync(import_path.default.join(__dirname, "./fixtures/query1.graphql"), {

@@ -99,4 +101,15 @@ encoding: "utf-8"

queryRunningSuite.add("supermassive - runtime schemaless", () => __async(void 0, null, function* () {
let extractedResolvers = {};
const getTypeByName = (name) => {
const type = import_values.specifiedScalars[name] || extractedResolvers[name];
if ((0, import_graphql.isInputType)(type)) {
return type;
} else {
throw new Error("Invalid type");
}
};
extractedResolvers = (0, import_extractImplicitTypesRuntime.extractImplicitTypes)(parsedQuery, getTypeByName);
const result = yield (0, import_executeWithoutSchema.executeWithoutSchema)({
resolvers: import_resolvers.default,
schemaResolvers: extractedResolvers,
document: typeAnnotatedQuery,

@@ -103,0 +116,0 @@ contextValue: {models: import_models.default}

27

lib/benchmarks/swapi-schema/__generated__/schema.d.ts

@@ -1,26 +0,3 @@

import { GraphQLEnumType } from "graphql";
export declare const resolvers: {
SearchResult: {
__types: string[];
__resolveType: undefined;
};
NodeType: GraphQLEnumType;
Subscription: {};
Query: {};
Node: {
__implementedBy: string[];
__resolveType: undefined;
};
Alive: {
__types: string[];
__resolveType: undefined;
};
Film: {};
Vehicle: {};
Person: {};
Starship: {};
Planet: {};
Species: {};
Transport: {};
};
import { Resolvers } from "@graphitation/supermassive";
export declare const resolvers: Resolvers;
//# sourceMappingURL=schema.d.ts.map

@@ -45,2 +45,3 @@ var __create = Object.create;

var import_definition = __toModule(require("./definition"));
var import_mergeResolvers = __toModule(require("./utilities/mergeResolvers"));
var import_typeNameFromAST = __toModule(require("./utilities/typeNameFromAST"));

@@ -51,2 +52,3 @@ var import_values = __toModule(require("./values"));

resolvers,
schemaResolvers,
document,

@@ -60,4 +62,5 @@ rootValue,

} = args;
const combinedResolvers = (0, import_mergeResolvers.mergeResolvers)(resolvers, schemaResolvers);
assertValidExecutionArguments(document, variableValues);
const exeContext = buildExecutionContext(resolvers, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver);
const exeContext = buildExecutionContext(combinedResolvers, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver);
if (!("resolvers" in exeContext)) {

@@ -64,0 +67,0 @@ return {errors: exeContext};

@@ -29,3 +29,2 @@ var __create = Object.create;

var import_index = __toModule(require("./index"));
var import_mergeResolvers = __toModule(require("./utilities/mergeResolvers"));
function executeWithSchema({

@@ -53,7 +52,7 @@ typeDefs,

extractedResolvers = (0, import_index.extractImplicitTypes)(typeDefs, getTypeByName);
const fullResolvers = (0, import_mergeResolvers.mergeResolvers)(resolvers, extractedResolvers);
const document = (0, import_index.addTypesToRequestDocument)(schema, rawDocument);
return (0, import_index.executeWithoutSchema)({
document,
resolvers: fullResolvers,
resolvers,
schemaResolvers: extractedResolvers,
rootValue,

@@ -60,0 +59,0 @@ contextValue,

@@ -36,6 +36,14 @@ var __create = Object.create;

};
const SUPERMASSIVE_TYPES = {
INTERFACE_TYPE_RESOLVER: "InterfaceTypeResolver",
UNION_TYPE_RESOLVER: "UnionTypeResolver",
OBJECT_TYPE_RESOLVER: "ObjectTypeResolver",
ENUM_TYPE_RESOLVER: "EnumTypeResolver",
SCALAR_TYPE_RESOLVER: "ScalarTypeResolver",
INPUT_OBJECT_TYPE_RESOLVER: "InputObjectTypeResolver"
};
function extractImplicitTypesToTypescript(document) {
var _a, _b;
const definitions = [];
const imports = [
const graphQLImports = [
"GraphQLList",

@@ -49,2 +57,3 @@ "GraphQLNonNull",

];
const supermassiveImports = ["Resolvers"];
const identifiers = [];

@@ -56,14 +65,18 @@ const implementedBy = {};

definitions.push(createScalarType(astNode));
addToSetArray(imports, "GraphQLScalarType");
addToSetArray(graphQLImports, "GraphQLScalarType");
addToSetArray(supermassiveImports, SUPERMASSIVE_TYPES.SCALAR_TYPE_RESOLVER);
addToSetArray(identifiers, astNode.name.value);
} else if (astNode.kind === import_graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION) {
definitions.push(createInputObjectType(astNode));
addToSetArray(imports, "GraphQLInputObjectType");
addToSetArray(graphQLImports, "GraphQLInputObjectType");
addToSetArray(supermassiveImports, SUPERMASSIVE_TYPES.INPUT_OBJECT_TYPE_RESOLVER);
addToSetArray(identifiers, astNode.name.value);
} else if (astNode.kind === import_graphql.Kind.ENUM_TYPE_DEFINITION) {
definitions.push(createEnumType(astNode));
addToSetArray(imports, "GraphQLEnumType");
addToSetArray(graphQLImports, "GraphQLEnumType");
addToSetArray(supermassiveImports, SUPERMASSIVE_TYPES.ENUM_TYPE_RESOLVER);
addToSetArray(identifiers, astNode.name.value);
} else if (astNode.kind === import_graphql.Kind.INTERFACE_TYPE_DEFINITION) {
interfaceAstNodes.push(astNode);
addToSetArray(supermassiveImports, SUPERMASSIVE_TYPES.INTERFACE_TYPE_RESOLVER);
addToSetArray(identifiers, astNode.name.value);

@@ -74,3 +87,4 @@ } else if (astNode.kind === import_graphql.Kind.UNION_TYPE_DEFINITION) {

});
definitions.push(createAbstractType(astNode, void 0, types));
definitions.push(createUnionType(astNode, types || []));
addToSetArray(supermassiveImports, SUPERMASSIVE_TYPES.UNION_TYPE_RESOLVER);
addToSetArray(identifiers, astNode.name.value);

@@ -85,2 +99,3 @@ } else if (astNode.kind === import_graphql.Kind.OBJECT_TYPE_DEFINITION) {

definitions.push(createObjectType(astNode));
addToSetArray(supermassiveImports, SUPERMASSIVE_TYPES.OBJECT_TYPE_RESOLVER);
addToSetArray(identifiers, astNode.name.value);

@@ -93,13 +108,19 @@ }

}
definitions.push(createAbstractType(astNode, implementedBy[astNode.name.value]));
definitions.push(createInterfaceType(astNode, implementedBy[astNode.name.value]));
});
const importDefinition = import_typescript.factory.createImportDeclaration(void 0, void 0, import_typescript.factory.createImportClause(false, void 0, import_typescript.factory.createNamedImports(imports.map((imp) => import_typescript.factory.createImportSpecifier(void 0, import_typescript.factory.createIdentifier(imp))))), import_typescript.factory.createStringLiteral("graphql"));
const graphQLImportDefinition = import_typescript.factory.createImportDeclaration(void 0, void 0, import_typescript.factory.createImportClause(false, void 0, import_typescript.factory.createNamedImports(graphQLImports.map((imp) => import_typescript.factory.createImportSpecifier(void 0, import_typescript.factory.createIdentifier(imp))))), import_typescript.factory.createStringLiteral("graphql"));
const supermassiveImportDefinition = import_typescript.factory.createImportDeclaration(void 0, void 0, import_typescript.factory.createImportClause(false, void 0, import_typescript.factory.createNamedImports(supermassiveImports.map((imp) => import_typescript.factory.createImportSpecifier(void 0, import_typescript.factory.createIdentifier(imp))))), import_typescript.factory.createStringLiteral("@graphitation/supermassive"));
const exportDefinition = import_typescript.factory.createVariableStatement([import_typescript.factory.createModifier(import_typescript.default.SyntaxKind.ExportKeyword)], import_typescript.factory.createVariableDeclarationList([
import_typescript.factory.createVariableDeclaration(import_typescript.factory.createIdentifier("resolvers"), void 0, void 0, import_typescript.factory.createObjectLiteralExpression(identifiers.map((def) => import_typescript.factory.createShorthandPropertyAssignment(import_typescript.factory.createIdentifier(def), void 0))))
import_typescript.factory.createVariableDeclaration(import_typescript.factory.createIdentifier("resolvers"), void 0, import_typescript.factory.createTypeReferenceNode(import_typescript.factory.createIdentifier("Resolvers"), void 0), import_typescript.factory.createObjectLiteralExpression(identifiers.map((def) => import_typescript.factory.createShorthandPropertyAssignment(import_typescript.factory.createIdentifier(def), void 0))))
], import_typescript.default.NodeFlags.Const));
return import_typescript.factory.createSourceFile([importDefinition, ...definitions, exportDefinition], import_typescript.factory.createToken(import_typescript.default.SyntaxKind.EndOfFileToken), 0);
return import_typescript.factory.createSourceFile([
graphQLImportDefinition,
supermassiveImportDefinition,
...definitions,
exportDefinition
], import_typescript.factory.createToken(import_typescript.default.SyntaxKind.EndOfFileToken), 0);
}
function createDeclaration(name, decl) {
function createDeclaration(name, decl, typeReferenceNode) {
return import_typescript.factory.createVariableStatement(void 0, import_typescript.factory.createVariableDeclarationList([
import_typescript.factory.createVariableDeclaration(import_typescript.factory.createIdentifier(name), void 0, void 0, decl)
import_typescript.factory.createVariableDeclaration(import_typescript.factory.createIdentifier(name), void 0, typeReferenceNode, decl)
], import_typescript.default.NodeFlags.Const));

@@ -114,3 +135,3 @@ }

], true)
]));
]), import_typescript.factory.createTypeReferenceNode(import_typescript.factory.createIdentifier(SUPERMASSIVE_TYPES.SCALAR_TYPE_RESOLVER), void 0));
}

@@ -125,3 +146,3 @@ function createInputObjectType(astNode) {

], true)
]));
]), import_typescript.factory.createTypeReferenceNode(import_typescript.factory.createIdentifier(SUPERMASSIVE_TYPES.INPUT_OBJECT_TYPE_RESOLVER), void 0));
}

@@ -154,19 +175,18 @@ function createInputFields(astNodes) {

])
]));
]), import_typescript.factory.createTypeReferenceNode(import_typescript.factory.createIdentifier(SUPERMASSIVE_TYPES.ENUM_TYPE_RESOLVER), void 0));
}
function createAbstractType(astNode, implementedBy, types) {
const properties = [];
if (implementedBy) {
properties.push(import_typescript.factory.createPropertyAssignment(import_typescript.factory.createIdentifier("__implementedBy"), import_typescript.factory.createArrayLiteralExpression(implementedBy.map((value) => import_typescript.factory.createStringLiteral(value)))));
}
if (types) {
properties.push(import_typescript.factory.createPropertyAssignment(import_typescript.factory.createIdentifier("__types"), import_typescript.factory.createArrayLiteralExpression(types.map((value) => import_typescript.factory.createStringLiteral(value)))));
}
function createUnionType(astNode, types) {
return createDeclaration(astNode.name.value, import_typescript.factory.createObjectLiteralExpression([
...properties,
import_typescript.factory.createPropertyAssignment(import_typescript.factory.createIdentifier("__types"), import_typescript.factory.createArrayLiteralExpression(types.map((value) => import_typescript.factory.createStringLiteral(value)))),
import_typescript.factory.createPropertyAssignment(import_typescript.factory.createIdentifier("__resolveType"), import_typescript.factory.createIdentifier("undefined"))
]));
]), import_typescript.factory.createTypeReferenceNode(import_typescript.factory.createIdentifier(SUPERMASSIVE_TYPES.UNION_TYPE_RESOLVER), void 0));
}
function createInterfaceType(astNode, implementedBy) {
return createDeclaration(astNode.name.value, import_typescript.factory.createObjectLiteralExpression([
import_typescript.factory.createPropertyAssignment(import_typescript.factory.createIdentifier("__implementedBy"), import_typescript.factory.createArrayLiteralExpression(implementedBy.map((value) => import_typescript.factory.createStringLiteral(value)))),
import_typescript.factory.createPropertyAssignment(import_typescript.factory.createIdentifier("__resolveType"), import_typescript.factory.createIdentifier("undefined"))
]), import_typescript.factory.createTypeReferenceNode(import_typescript.factory.createIdentifier(SUPERMASSIVE_TYPES.INTERFACE_TYPE_RESOLVER), void 0));
}
function createObjectType(astNode) {
return createDeclaration(astNode.name.value, import_typescript.factory.createObjectLiteralExpression());
return createDeclaration(astNode.name.value, import_typescript.factory.createObjectLiteralExpression(), import_typescript.factory.createTypeReferenceNode(import_typescript.factory.createIdentifier(SUPERMASSIVE_TYPES.OBJECT_TYPE_RESOLVER), void 0));
}

@@ -173,0 +193,0 @@ function createType(astNode) {

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

export { subscribeWithoutSchema } from "./subscribeWithoutSchema";
export type { Resolvers } from "./types";
export type { ObjectTypeResolver, InterfaceTypeResolver, UnionTypeResolver, ScalarTypeResolver, EnumTypeResolver, InputObjectTypeResolver, Resolvers, } from "./types";
export { addTypesToRequestDocument } from "./ast/addTypesToRequestDocument";

@@ -8,0 +8,0 @@ export { extractImplicitTypes } from "./extractImplicitTypesRuntime";

@@ -56,2 +56,3 @@ var __create = Object.create;

var import_typeNameFromAST = __toModule(require("./utilities/typeNameFromAST"));
var import_mergeResolvers = __toModule(require("./utilities/mergeResolvers"));
var import_mapAsyncIterator = __toModule(require("./utilities/mapAsyncIterator"));

@@ -62,2 +63,3 @@ function subscribeWithoutSchema(args) {

resolvers,
schemaResolvers,
document,

@@ -71,3 +73,4 @@ rootValue,

} = args;
const resultOrStream = yield createSourceEventStream(resolvers, document, rootValue, contextValue, variableValues, operationName, subscribeFieldResolver);
const combinedResolvers = (0, import_mergeResolvers.mergeResolvers)(resolvers, schemaResolvers);
const resultOrStream = yield createSourceEventStream(combinedResolvers, document, rootValue, contextValue, variableValues, operationName, subscribeFieldResolver);
if (!(0, import_isAsyncIterable.isAsyncIterable)(resultOrStream)) {

@@ -78,2 +81,3 @@ return resultOrStream;

resolvers,
schemaResolvers,
document,

@@ -80,0 +84,0 @@ rootValue: payload,

@@ -7,16 +7,2 @@ var __create = Object.create;

var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
var __objSpread = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});

@@ -66,7 +52,7 @@ var __export = (target, all) => {

extractedResolvers = (0, import_index.extractImplicitTypes)(typeDefs, getTypeByName);
const fullResolvers = __objSpread(__objSpread({}, extractedResolvers), resolvers);
const document = (0, import_index.addTypesToRequestDocument)(schema, rawDocument);
return (0, import_index.subscribeWithoutSchema)({
document,
resolvers: fullResolvers,
resolvers,
schemaResolvers: extractedResolvers,
rootValue,

@@ -73,0 +59,0 @@ contextValue,

@@ -19,6 +19,6 @@ import { GraphQLEnumType, GraphQLError, GraphQLFormattedError, GraphQLInputObjectType, GraphQLScalarType, DocumentNode as UntypedDocumentNode } from "graphql";

export declare type InterfaceTypeResolver<TSource = any, TContext = any, TArgs = any> = {
[key: string]: FieldResolver<TSource, TContext, TArgs>;
__implementedBy: string[];
[key: string]: FieldResolver<TSource, TContext, TArgs> | string[] | undefined;
} & {
__resolveType?: TypeResolver<any, any>;
__implementedBy: string[];
};

@@ -29,5 +29,15 @@ export declare type UnionTypeResolver = {

};
export declare type UserInterfaceTypeResolver<TSource = any, TContext = any, TArgs = any> = {
[key: string]: FieldResolver<TSource, TContext, TArgs>;
} & {
__resolveType?: TypeResolver<any, any>;
};
export declare type UserUnionTypeResolver = {
__resolveType?: TypeResolver<any, any>;
};
export declare type InputObjectTypeResolver = GraphQLInputObjectType;
export declare type UserResolver<TSource, TContext> = ObjectTypeResolver<TSource, TContext> | UserInterfaceTypeResolver<TSource, TContext> | UserUnionTypeResolver | ScalarTypeResolver | EnumTypeResolver | InputObjectTypeResolver;
export declare type Resolver<TSource, TContext> = ObjectTypeResolver<TSource, TContext> | InterfaceTypeResolver<TSource, TContext> | UnionTypeResolver | ScalarTypeResolver | EnumTypeResolver | InputObjectTypeResolver;
export declare type Resolvers<TSource = any, TContext = any> = Record<string, Resolver<TSource, TContext>>;
export declare type UserResolvers<TSource = any, TContext = any> = Record<string, UserResolver<TSource, TContext>>;
export interface ResolveInfo {

@@ -65,3 +75,3 @@ fieldName: string;

export interface CommonExecutionArgs {
resolvers: Resolvers;
resolvers: UserResolvers;
rootValue?: unknown;

@@ -79,2 +89,3 @@ contextValue?: unknown;

document: DocumentNode;
schemaResolvers: Resolvers;
};

@@ -81,0 +92,0 @@ export declare type ExecutionWithSchemaArgs = CommonExecutionArgs & {

@@ -1,3 +0,3 @@

import { Resolvers, Resolver } from "../types";
export declare function mergeResolvers(resolvers: Resolvers<any, any>, extractedResolvers: Record<string, Resolver<any, any>>): Record<string, Resolver<any, any>>;
import { UserResolvers, Resolvers } from "../types";
export declare function mergeResolvers(resolvers: UserResolvers<any, any>, extractedResolvers: Resolvers): Resolvers<any, any>;
//# sourceMappingURL=mergeResolvers.d.ts.map
{
"name": "@graphitation/supermassive",
"license": "MIT",
"version": "0.7.2",
"version": "0.8.0",
"bin": {

@@ -17,3 +17,3 @@ "supermassive": "./bin/supermassive.js"

"lint": "monorepo-scripts lint",
"test": "supermassive extract-schema ./src/benchmarks/swapi-schema/schema.graphql && monorepo-scripts test",
"test": "./bin/supermassive.js extract-schema ./src/benchmarks/swapi-schema/schema.graphql && monorepo-scripts test",
"types": "monorepo-scripts types",

@@ -20,0 +20,0 @@ "just": "monorepo-scripts",

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

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