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

type-graphql

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

type-graphql - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0-rc.1

4

dist/decorators/Arg.d.ts

@@ -1,4 +0,4 @@

import { ReturnTypeFunc, DecoratorTypeOptions, DescriptionOptions, ValidateOptions } from "./types";
export declare type ArgOptions = DecoratorTypeOptions & DescriptionOptions & ValidateOptions;
import { ReturnTypeFunc, DecoratorTypeOptions, DescriptionOptions, ValidateOptions, DeprecationOptions } from "./types";
export declare type ArgOptions = DecoratorTypeOptions & DescriptionOptions & ValidateOptions & DeprecationOptions;
export declare function Arg(name: string, options?: ArgOptions): ParameterDecorator;
export declare function Arg(name: string, returnTypeFunc: ReturnTypeFunc, options?: ArgOptions): ParameterDecorator;

@@ -9,8 +9,9 @@ "use strict";

return (prototype, propertyKey, parameterIndex) => {
const { options, returnTypeFunc } = decorators_1.getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions);
getMetadataStorage_1.getMetadataStorage().collectHandlerParamMetadata({
const { options, returnTypeFunc } = (0, decorators_1.getTypeDecoratorParams)(returnTypeFuncOrOptions, maybeOptions);
(0, getMetadataStorage_1.getMetadataStorage)().collectHandlerParamMetadata({
kind: "arg",
name,
description: options.description,
...params_1.getParamInfo({
deprecationReason: options.deprecationReason,
...(0, params_1.getParamInfo)({
prototype,

@@ -17,0 +18,0 @@ propertyKey,

@@ -8,7 +8,7 @@ "use strict";

function Args(paramTypeFnOrOptions, maybeOptions) {
const { options, returnTypeFunc } = decorators_1.getTypeDecoratorParams(paramTypeFnOrOptions, maybeOptions);
const { options, returnTypeFunc } = (0, decorators_1.getTypeDecoratorParams)(paramTypeFnOrOptions, maybeOptions);
return (prototype, propertyKey, parameterIndex) => {
getMetadataStorage_1.getMetadataStorage().collectHandlerParamMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectHandlerParamMetadata({
kind: "args",
...params_1.getParamInfo({ prototype, propertyKey, parameterIndex, returnTypeFunc, options }),
...(0, params_1.getParamInfo)({ prototype, propertyKey, parameterIndex, returnTypeFunc, options }),
});

@@ -15,0 +15,0 @@ };

@@ -7,3 +7,3 @@ "use strict";

return target => {
getMetadataStorage_1.getMetadataStorage().collectArgsMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectArgsMetadata({
name: target.name,

@@ -10,0 +10,0 @@ target,

import { MethodAndPropDecorator } from "./types";
export declare function Authorized(): MethodAndPropDecorator;
export declare function Authorized<RoleType = string>(roles: RoleType[]): MethodAndPropDecorator;
export declare function Authorized<RoleType = string>(...roles: RoleType[]): MethodAndPropDecorator;
export declare function Authorized<RoleType = string>(roles: readonly RoleType[]): MethodAndPropDecorator;
export declare function Authorized<RoleType = string>(...roles: readonly RoleType[]): MethodAndPropDecorator;

@@ -8,3 +8,3 @@ "use strict";

function Authorized(...rolesOrRolesArray) {
const roles = decorators_1.getArrayFromOverloadedRest(rolesOrRolesArray);
const roles = (0, decorators_1.getArrayFromOverloadedRest)(rolesOrRolesArray);
return (prototype, propertyKey, descriptor) => {

@@ -14,3 +14,3 @@ if (typeof propertyKey === "symbol") {

}
getMetadataStorage_1.getMetadataStorage().collectAuthorizedFieldMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectAuthorizedFieldMetadata({
target: prototype.constructor,

@@ -17,0 +17,0 @@ fieldName: propertyKey,

@@ -6,4 +6,4 @@ "use strict";

function createMethodDecorator(resolver) {
return UseMiddleware_1.UseMiddleware(resolver);
return (0, UseMiddleware_1.UseMiddleware)(resolver);
}
exports.createMethodDecorator = createMethodDecorator;

@@ -11,3 +11,3 @@ "use strict";

}
getMetadataStorage_1.getMetadataStorage().collectHandlerParamMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectHandlerParamMetadata({
kind: "custom",

@@ -14,0 +14,0 @@ target: prototype.constructor,

@@ -11,3 +11,3 @@ "use strict";

}
getMetadataStorage_1.getMetadataStorage().collectHandlerParamMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectHandlerParamMetadata({
kind: "context",

@@ -14,0 +14,0 @@ target: prototype.constructor,

@@ -13,3 +13,3 @@ "use strict";

if (propertyKey) {
getMetadataStorage_1.getMetadataStorage().collectDirectiveFieldMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectDirectiveFieldMetadata({
target: targetOrPrototype.constructor,

@@ -21,3 +21,3 @@ fieldName: propertyKey,

else {
getMetadataStorage_1.getMetadataStorage().collectDirectiveClassMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectDirectiveClassMetadata({
target: targetOrPrototype,

@@ -24,0 +24,0 @@ directive,

@@ -6,3 +6,3 @@ "use strict";

function registerEnumType(enumObj, enumConfig) {
getMetadataStorage_1.getMetadataStorage().collectEnumMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectEnumMetadata({
enumObj,

@@ -9,0 +9,0 @@ name: enumConfig.name,

@@ -12,3 +12,3 @@ "use strict";

if (propertyKey) {
getMetadataStorage_1.getMetadataStorage().collectExtensionsFieldMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectExtensionsFieldMetadata({
target: targetOrPrototype.constructor,

@@ -20,3 +20,3 @@ fieldName: propertyKey,

else {
getMetadataStorage_1.getMetadataStorage().collectExtensionsClassMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectExtensionsClassMetadata({
target: targetOrPrototype,

@@ -23,0 +23,0 @@ extensions,

@@ -13,6 +13,6 @@ "use strict";

}
const { options, returnTypeFunc } = decorators_1.getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions);
const { options, returnTypeFunc } = (0, decorators_1.getTypeDecoratorParams)(returnTypeFuncOrOptions, maybeOptions);
const isResolver = Boolean(descriptor);
const isResolverMethod = Boolean(descriptor && descriptor.value);
const { getType, typeOptions } = findType_1.findType({
const { getType, typeOptions } = (0, findType_1.findType)({
metadataKey: isResolverMethod ? "design:returntype" : "design:type",

@@ -24,3 +24,3 @@ prototype,

});
getMetadataStorage_1.getMetadataStorage().collectClassFieldMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectClassFieldMetadata({
name: propertyKey,

@@ -37,3 +37,3 @@ schemaName: options.name || propertyKey,

if (isResolver) {
getMetadataStorage_1.getMetadataStorage().collectFieldResolverMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectFieldResolverMetadata({
kind: "internal",

@@ -40,0 +40,0 @@ methodName: propertyKey,

@@ -15,6 +15,6 @@ "use strict";

let typeOptions;
const { options, returnTypeFunc } = decorators_1.getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions);
const { options, returnTypeFunc } = (0, decorators_1.getTypeDecoratorParams)(returnTypeFuncOrOptions, maybeOptions);
// try to get return type info
try {
const typeInfo = findType_1.findType({
const typeInfo = (0, findType_1.findType)({
metadataKey: "design:returntype",

@@ -32,3 +32,3 @@ prototype,

}
getMetadataStorage_1.getMetadataStorage().collectFieldResolverMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectFieldResolverMetadata({
kind: "external",

@@ -35,0 +35,0 @@ methodName: propertyKey,

@@ -11,3 +11,3 @@ "use strict";

}
getMetadataStorage_1.getMetadataStorage().collectHandlerParamMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectHandlerParamMetadata({
kind: "info",

@@ -14,0 +14,0 @@ target: prototype.constructor,

@@ -7,5 +7,5 @@ "use strict";

function InputType(nameOrOptions, maybeOptions) {
const { name, options } = decorators_1.getNameDecoratorParams(nameOrOptions, maybeOptions);
const { name, options } = (0, decorators_1.getNameDecoratorParams)(nameOrOptions, maybeOptions);
return target => {
getMetadataStorage_1.getMetadataStorage().collectInputMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectInputMetadata({
name: name || target.name,

@@ -12,0 +12,0 @@ target,

@@ -7,6 +7,6 @@ "use strict";

function InterfaceType(nameOrOptions, maybeOptions) {
const { name, options } = decorators_1.getNameDecoratorParams(nameOrOptions, maybeOptions);
const { name, options } = (0, decorators_1.getNameDecoratorParams)(nameOrOptions, maybeOptions);
const interfaceClasses = options.implements && [].concat(options.implements);
return target => {
getMetadataStorage_1.getMetadataStorage().collectInterfaceMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectInterfaceMetadata({
name: name || target.name,

@@ -13,0 +13,0 @@ target,

@@ -8,8 +8,8 @@ "use strict";

function Mutation(returnTypeFuncOrOptions, maybeOptions) {
const { options, returnTypeFunc } = decorators_1.getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions);
const { options, returnTypeFunc } = (0, decorators_1.getTypeDecoratorParams)(returnTypeFuncOrOptions, maybeOptions);
return (prototype, methodName) => {
const metadata = resolver_metadata_1.getResolverMetadata(prototype, methodName, returnTypeFunc, options);
getMetadataStorage_1.getMetadataStorage().collectMutationHandlerMetadata(metadata);
const metadata = (0, resolver_metadata_1.getResolverMetadata)(prototype, methodName, returnTypeFunc, options);
(0, getMetadataStorage_1.getMetadataStorage)().collectMutationHandlerMetadata(metadata);
};
}
exports.Mutation = Mutation;

@@ -7,6 +7,6 @@ "use strict";

function ObjectType(nameOrOptions, maybeOptions) {
const { name, options } = decorators_1.getNameDecoratorParams(nameOrOptions, maybeOptions);
const { name, options } = (0, decorators_1.getNameDecoratorParams)(nameOrOptions, maybeOptions);
const interfaceClasses = options.implements && [].concat(options.implements);
return target => {
getMetadataStorage_1.getMetadataStorage().collectObjectMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectObjectMetadata({
name: name || target.name,

@@ -13,0 +13,0 @@ target,

@@ -11,3 +11,3 @@ "use strict";

}
getMetadataStorage_1.getMetadataStorage().collectHandlerParamMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectHandlerParamMetadata({
kind: "pubSub",

@@ -14,0 +14,0 @@ target: prototype.constructor,

@@ -8,8 +8,8 @@ "use strict";

function Query(returnTypeFuncOrOptions, maybeOptions) {
const { options, returnTypeFunc } = decorators_1.getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions);
const { options, returnTypeFunc } = (0, decorators_1.getTypeDecoratorParams)(returnTypeFuncOrOptions, maybeOptions);
return (prototype, methodName) => {
const metadata = resolver_metadata_1.getResolverMetadata(prototype, methodName, returnTypeFunc, options);
getMetadataStorage_1.getMetadataStorage().collectQueryHandlerMetadata(metadata);
const metadata = (0, resolver_metadata_1.getResolverMetadata)(prototype, methodName, returnTypeFunc, options);
(0, getMetadataStorage_1.getMetadataStorage)().collectQueryHandlerMetadata(metadata);
};
}
exports.Query = Query;

@@ -20,3 +20,3 @@ "use strict";

};
getMetadataStorage_1.getMetadataStorage().collectResolverClassMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectResolverClassMetadata({
target,

@@ -23,0 +23,0 @@ getObjectType,

@@ -14,3 +14,3 @@ "use strict";

try {
const typeInfo = findType_1.findType({
const typeInfo = (0, findType_1.findType)({
metadataKey: "design:paramtypes",

@@ -26,3 +26,3 @@ prototype,

}
getMetadataStorage_1.getMetadataStorage().collectHandlerParamMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectHandlerParamMetadata({
kind: "root",

@@ -29,0 +29,0 @@ target: prototype.constructor,

@@ -9,10 +9,10 @@ "use strict";

function Subscription(returnTypeFuncOrOptions, maybeOptions) {
const params = decorators_1.getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions);
const params = (0, decorators_1.getTypeDecoratorParams)(returnTypeFuncOrOptions, maybeOptions);
const options = params.options;
return (prototype, methodName) => {
const metadata = resolver_metadata_1.getResolverMetadata(prototype, methodName, params.returnTypeFunc, options);
const metadata = (0, resolver_metadata_1.getResolverMetadata)(prototype, methodName, params.returnTypeFunc, options);
if (Array.isArray(options.topics) && options.topics.length === 0) {
throw new errors_1.MissingSubscriptionTopicsError(metadata.target, metadata.methodName);
}
getMetadataStorage_1.getMetadataStorage().collectSubscriptionHandlerMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectSubscriptionHandlerMetadata({
...metadata,

@@ -19,0 +19,0 @@ topics: options.topics,

@@ -6,3 +6,3 @@ "use strict";

function createUnionType({ name, description, types, resolveType, }) {
const unionMetadataSymbol = getMetadataStorage_1.getMetadataStorage().collectUnionMetadata({
const unionMetadataSymbol = (0, getMetadataStorage_1.getMetadataStorage)().collectUnionMetadata({
name,

@@ -9,0 +9,0 @@ description,

@@ -8,3 +8,3 @@ "use strict";

function UseMiddleware(...middlewaresOrMiddlewareArray) {
const middlewares = decorators_1.getArrayFromOverloadedRest(middlewaresOrMiddlewareArray);
const middlewares = (0, decorators_1.getArrayFromOverloadedRest)(middlewaresOrMiddlewareArray);
return (prototype, propertyKey, descriptor) => {

@@ -14,3 +14,3 @@ if (typeof propertyKey === "symbol") {

}
getMetadataStorage_1.getMetadataStorage().collectMiddlewareMetadata({
(0, getMetadataStorage_1.getMetadataStorage)().collectMiddlewareMetadata({
target: prototype.constructor,

@@ -17,0 +17,0 @@ fieldName: propertyKey,

@@ -6,3 +6,2 @@ export * from "./ArgumentValidationError";

export * from "./ConflictingDefaultValuesError";
export * from "./ConflictingDefaultWithNullableError";
export * from "./InterfaceResolveTypeError";

@@ -9,0 +8,0 @@ export * from "./InvalidDirectiveError";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./ArgumentValidationError"), exports);
tslib_1.__exportStar(require("./CannotDetermineGraphQLTypeError"), exports);
tslib_1.__exportStar(require("./ForbiddenError"), exports);
tslib_1.__exportStar(require("./GeneratingSchemaError"), exports);
tslib_1.__exportStar(require("./ConflictingDefaultValuesError"), exports);
tslib_1.__exportStar(require("./ConflictingDefaultWithNullableError"), exports);
tslib_1.__exportStar(require("./InterfaceResolveTypeError"), exports);
tslib_1.__exportStar(require("./InvalidDirectiveError"), exports);
tslib_1.__exportStar(require("./MissingSubscriptionTopicsError"), exports);
tslib_1.__exportStar(require("./NoExplicitTypeError"), exports);
tslib_1.__exportStar(require("./ReflectMetadataMissingError"), exports);
tslib_1.__exportStar(require("./SymbolKeysNotSupportedError"), exports);
tslib_1.__exportStar(require("./UnauthorizedError"), exports);
tslib_1.__exportStar(require("./UnionResolveTypeError"), exports);
tslib_1.__exportStar(require("./UnmetGraphQLPeerDependencyError"), exports);
tslib_1.__exportStar(require("./WrongNullableListOptionError"), exports);
(0, tslib_1.__exportStar)(require("./ArgumentValidationError"), exports);
(0, tslib_1.__exportStar)(require("./CannotDetermineGraphQLTypeError"), exports);
(0, tslib_1.__exportStar)(require("./ForbiddenError"), exports);
(0, tslib_1.__exportStar)(require("./GeneratingSchemaError"), exports);
(0, tslib_1.__exportStar)(require("./ConflictingDefaultValuesError"), exports);
(0, tslib_1.__exportStar)(require("./InterfaceResolveTypeError"), exports);
(0, tslib_1.__exportStar)(require("./InvalidDirectiveError"), exports);
(0, tslib_1.__exportStar)(require("./MissingSubscriptionTopicsError"), exports);
(0, tslib_1.__exportStar)(require("./NoExplicitTypeError"), exports);
(0, tslib_1.__exportStar)(require("./ReflectMetadataMissingError"), exports);
(0, tslib_1.__exportStar)(require("./SymbolKeysNotSupportedError"), exports);
(0, tslib_1.__exportStar)(require("./UnauthorizedError"), exports);
(0, tslib_1.__exportStar)(require("./UnionResolveTypeError"), exports);
(0, tslib_1.__exportStar)(require("./UnmetGraphQLPeerDependencyError"), exports);
(0, tslib_1.__exportStar)(require("./WrongNullableListOptionError"), exports);

@@ -7,5 +7,5 @@ "use strict";

constructor() {
super(`Looks like you use an incorrect version of the 'graphql' package: "${graphql_version_1.getInstalledGraphQLVersion()}". ` +
super(`Looks like you use an incorrect version of the 'graphql' package: "${(0, graphql_version_1.getInstalledGraphQLVersion)()}". ` +
`Please ensure that you have installed a version ` +
`that meets TypeGraphQL's requirement: "${graphql_version_1.getPeerDependencyGraphQLRequirement()}".`);
`that meets TypeGraphQL's requirement: "${(0, graphql_version_1.getPeerDependencyGraphQLRequirement)()}".`);
Object.setPrototypeOf(this, new.target.prototype);

@@ -12,0 +12,0 @@ }

import { MiddlewareFn } from "../interfaces/Middleware";
import { AuthChecker, AuthMode } from "../interfaces";
export declare function AuthMiddleware(authChecker: AuthChecker<any, any>, authMode: AuthMode, roles: any[]): MiddlewareFn;
import { IOCContainer } from "../utils/container";
export declare function AuthMiddleware(authChecker: AuthChecker<any, any>, container: IOCContainer, authMode: AuthMode, roles: any[]): MiddlewareFn;

@@ -5,5 +5,12 @@ "use strict";

const errors_1 = require("../errors");
function AuthMiddleware(authChecker, authMode, roles) {
function AuthMiddleware(authChecker, container, authMode, roles) {
return async (action, next) => {
const accessGranted = await authChecker(action, roles);
let accessGranted;
if (authChecker.prototype) {
const authCheckerInstance = await container.getInstance(authChecker, action);
accessGranted = await authCheckerInstance.check(action, roles);
}
else {
accessGranted = await authChecker(action, roles);
}
if (!accessGranted) {

@@ -10,0 +17,0 @@ if (authMode === "null") {

@@ -14,2 +14,2 @@ import { ReturnTypeFunc, DescriptionOptions } from "../decorators/types";

};
export declare function getArrayFromOverloadedRest<T>(overloadedArray: Array<T | T[]>): T[];
export declare function getArrayFromOverloadedRest<T>(overloadedArray: Array<T | readonly T[]>): T[];
/// <reference types="node" />
import * as fs from "fs";
import fs from "fs";
export declare const fsMkdir: typeof fs.mkdir.__promisify__;

@@ -4,0 +4,0 @@ export declare const fsWriteFile: typeof fs.writeFile.__promisify__;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.outputFileSync = exports.outputFile = exports.mkdirRecursiveSync = exports.mkdirRecursive = exports.parsePath = exports.fsWriteFile = exports.fsMkdir = void 0;
const path = require("path");
const fs = require("fs");
const tslib_1 = require("tslib");
const path_1 = (0, tslib_1.__importDefault)(require("path"));
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
const util_1 = require("util");
exports.fsMkdir = util_1.promisify(fs.mkdir);
exports.fsWriteFile = util_1.promisify(fs.writeFile);
exports.fsMkdir = (0, util_1.promisify)(fs_1.default.mkdir);
exports.fsWriteFile = (0, util_1.promisify)(fs_1.default.writeFile);
function parsePath(targetPath) {
const directories = [];
const parsedPath = path.parse(path.resolve(targetPath));
const splitPath = parsedPath.dir.split(path.sep);
const parsedPath = path_1.default.parse(path_1.default.resolve(targetPath));
const splitPath = parsedPath.dir.split(path_1.default.sep);
if (parsedPath.root === "/") {

@@ -17,5 +18,5 @@ splitPath[0] = `/${splitPath[0]}`;

splitPath.reduce((previous, next) => {
const directory = path.join(previous, next);
const directory = path_1.default.join(previous, next);
directories.push(directory);
return path.join(directory);
return path_1.default.join(directory);
});

@@ -29,3 +30,3 @@ return directories;

try {
await exports.fsMkdir(directory);
await (0, exports.fsMkdir)(directory);
}

@@ -43,4 +44,4 @@ catch (err) {

for (const directory of directories) {
if (!fs.existsSync(directory)) {
fs.mkdirSync(directory);
if (!fs_1.default.existsSync(directory)) {
fs_1.default.mkdirSync(directory);
}

@@ -52,3 +53,3 @@ }

try {
await exports.fsWriteFile(filePath, fileContent);
await (0, exports.fsWriteFile)(filePath, fileContent);
}

@@ -60,3 +61,3 @@ catch (err) {

await mkdirRecursive(filePath);
await exports.fsWriteFile(filePath, fileContent);
await (0, exports.fsWriteFile)(filePath, fileContent);
}

@@ -67,3 +68,3 @@ }

try {
fs.writeFileSync(filePath, fileContent);
fs_1.default.writeFileSync(filePath, fileContent);
}

@@ -75,5 +76,5 @@ catch (e) {

mkdirRecursiveSync(filePath);
fs.writeFileSync(filePath, fileContent);
fs_1.default.writeFileSync(filePath, fileContent);
}
}
exports.outputFileSync = outputFileSync;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadResolversFromGlob = exports.findFileNamesFromGlob = void 0;
const glob = require("glob");
const tslib_1 = require("tslib");
const glob_1 = (0, tslib_1.__importDefault)(require("glob"));
function findFileNamesFromGlob(globString) {
return glob.sync(globString);
return glob_1.default.sync(globString);
}

@@ -8,0 +9,0 @@ exports.findFileNamesFromGlob = findFileNamesFromGlob;

@@ -10,3 +10,3 @@ "use strict";

}
const { getType, typeOptions } = findType_1.findType({
const { getType, typeOptions } = (0, findType_1.findType)({
metadataKey: "design:paramtypes",

@@ -13,0 +13,0 @@ prototype,

@@ -10,3 +10,3 @@ "use strict";

}
const { getType, typeOptions } = findType_1.findType({
const { getType, typeOptions } = (0, findType_1.findType)({
metadataKey: "design:returntype",

@@ -13,0 +13,0 @@ prototype,

@@ -36,6 +36,2 @@ "use strict";

}
if (typeOptions.defaultValue !== undefined &&
(typeOptions.nullable === false || typeOptions.nullable === "items")) {
throw new errors_1.ConflictingDefaultWithNullableError(target.name, propertyName, typeOptions.defaultValue, typeOptions.nullable);
}
let gqlType = type;

@@ -48,6 +44,5 @@ if (typeOptions.array) {

}
if (typeOptions.defaultValue === undefined &&
(typeOptions.nullable === false ||
(typeOptions.nullable === undefined && nullableByDefault === false) ||
typeOptions.nullable === "items")) {
if (typeOptions.nullable === false ||
(typeOptions.nullable === undefined && nullableByDefault === false) ||
typeOptions.nullable === "items") {
gqlType = new graphql_1.GraphQLNonNull(gqlType);

@@ -54,0 +49,0 @@ }

@@ -5,9 +5,9 @@ "use strict";

const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./decorators"), exports);
tslib_1.__exportStar(require("./errors"), exports);
tslib_1.__exportStar(require("./interfaces"), exports);
tslib_1.__exportStar(require("./metadata"), exports);
tslib_1.__exportStar(require("./scalars"), exports);
tslib_1.__exportStar(require("./utils"), exports);
(0, tslib_1.__exportStar)(require("./decorators"), exports);
(0, tslib_1.__exportStar)(require("./errors"), exports);
(0, tslib_1.__exportStar)(require("./interfaces"), exports);
(0, tslib_1.__exportStar)(require("./metadata"), exports);
(0, tslib_1.__exportStar)(require("./scalars"), exports);
(0, tslib_1.__exportStar)(require("./utils"), exports);
var graphql_subscriptions_1 = require("graphql-subscriptions");
Object.defineProperty(exports, "PubSubEngine", { enumerable: true, get: function () { return graphql_subscriptions_1.PubSubEngine; } });

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

import { ClassType } from "./ClassType";
import { ResolverData } from "./ResolverData";
export declare type AuthChecker<ContextType = {}, RoleType = string> = (resolverData: ResolverData<ContextType>, roles: RoleType[]) => boolean | Promise<boolean>;
export declare type AuthCheckerFn<TContextType = {}, TRoleType = string> = (resolverData: ResolverData<TContextType>, roles: TRoleType[]) => boolean | Promise<boolean>;
export declare type AuthCheckerInterface<TContextType = {}, TRoleType = string> = {
check(resolverData: ResolverData<TContextType>, roles: TRoleType[]): boolean | Promise<boolean>;
};
export declare type AuthChecker<TContextType = {}, TRoleType = string> = AuthCheckerFn<TContextType, TRoleType> | ClassType<AuthCheckerInterface<TContextType, TRoleType>>;
export declare type AuthMode = "error" | "null";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./AuthChecker"), exports);
tslib_1.__exportStar(require("./ClassType"), exports);
tslib_1.__exportStar(require("./Complexity"), exports);
tslib_1.__exportStar(require("./Maybe"), exports);
tslib_1.__exportStar(require("./NonEmptyArray"), exports);
tslib_1.__exportStar(require("./Publisher"), exports);
tslib_1.__exportStar(require("./ResolverData"), exports);
tslib_1.__exportStar(require("./ResolverFilterData"), exports);
tslib_1.__exportStar(require("./ResolverInterface"), exports);
tslib_1.__exportStar(require("./resolvers-map"), exports);
tslib_1.__exportStar(require("./ResolverTopicData"), exports);
tslib_1.__exportStar(require("./TypeResolver"), exports);
(0, tslib_1.__exportStar)(require("./AuthChecker"), exports);
(0, tslib_1.__exportStar)(require("./ClassType"), exports);
(0, tslib_1.__exportStar)(require("./Complexity"), exports);
(0, tslib_1.__exportStar)(require("./Maybe"), exports);
(0, tslib_1.__exportStar)(require("./NonEmptyArray"), exports);
(0, tslib_1.__exportStar)(require("./Publisher"), exports);
(0, tslib_1.__exportStar)(require("./ResolverData"), exports);
(0, tslib_1.__exportStar)(require("./ResolverFilterData"), exports);
(0, tslib_1.__exportStar)(require("./ResolverInterface"), exports);
(0, tslib_1.__exportStar)(require("./resolvers-map"), exports);
(0, tslib_1.__exportStar)(require("./ResolverTopicData"), exports);
(0, tslib_1.__exportStar)(require("./TypeResolver"), exports);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./authorized-metadata"), exports);
tslib_1.__exportStar(require("./class-metadata"), exports);
tslib_1.__exportStar(require("./directive-metadata"), exports);
tslib_1.__exportStar(require("./enum-metadata"), exports);
tslib_1.__exportStar(require("./extensions-metadata"), exports);
tslib_1.__exportStar(require("./field-metadata"), exports);
tslib_1.__exportStar(require("./middleware-metadata"), exports);
tslib_1.__exportStar(require("./param-metadata"), exports);
tslib_1.__exportStar(require("./resolver-metadata"), exports);
tslib_1.__exportStar(require("./union-metadata"), exports);
(0, tslib_1.__exportStar)(require("./authorized-metadata"), exports);
(0, tslib_1.__exportStar)(require("./class-metadata"), exports);
(0, tslib_1.__exportStar)(require("./directive-metadata"), exports);
(0, tslib_1.__exportStar)(require("./enum-metadata"), exports);
(0, tslib_1.__exportStar)(require("./extensions-metadata"), exports);
(0, tslib_1.__exportStar)(require("./field-metadata"), exports);
(0, tslib_1.__exportStar)(require("./middleware-metadata"), exports);
(0, tslib_1.__exportStar)(require("./param-metadata"), exports);
(0, tslib_1.__exportStar)(require("./resolver-metadata"), exports);
(0, tslib_1.__exportStar)(require("./union-metadata"), exports);

@@ -34,2 +34,3 @@ import { TypeValueThunk, TypeOptions } from "../../decorators/types";

description: string | undefined;
deprecationReason: string | undefined;
}

@@ -36,0 +37,0 @@ export interface ArgsParamMetadata extends CommonArgMetadata {

@@ -27,3 +27,3 @@ "use strict";

this.params = [];
utils_1.ensureReflectMetadataExists();
(0, utils_1.ensureReflectMetadataExists)();
}

@@ -93,3 +93,2 @@ collectQueryHandlerMetadata(definition) {

build(options) {
// TODO: disable next build attempts
this.classDirectives.reverse();

@@ -137,3 +136,3 @@ this.fieldDirectives.reverse();

field.params = this.params.filter(param => param.target === field.target && field.name === param.methodName);
field.middlewares = utils_1.mapMiddlewareMetadataToArray(this.middlewares.filter(middleware => middleware.target === field.target && middleware.fieldName === field.name));
field.middlewares = (0, utils_1.mapMiddlewareMetadataToArray)(this.middlewares.filter(middleware => middleware.target === field.target && middleware.fieldName === field.name));
field.directives = this.fieldDirectives

@@ -162,3 +161,3 @@ .filter(it => it.target === field.target && it.fieldName === field.name)

def.roles = this.findFieldRoles(def.target, def.methodName);
def.middlewares = utils_1.mapMiddlewareMetadataToArray(this.middlewares.filter(middleware => middleware.target === def.target && def.methodName === middleware.fieldName));
def.middlewares = (0, utils_1.mapMiddlewareMetadataToArray)(this.middlewares.filter(middleware => middleware.target === def.target && def.methodName === middleware.fieldName));
def.directives = this.fieldDirectives

@@ -240,6 +239,6 @@ .filter(it => it.target === def.target && it.fieldName === def.methodName)

if (superResolverMetadata) {
this.queries = utils_1.mapSuperResolverHandlers(this.queries, superResolver, def);
this.mutations = utils_1.mapSuperResolverHandlers(this.mutations, superResolver, def);
this.subscriptions = utils_1.mapSuperResolverHandlers(this.subscriptions, superResolver, def);
this.fieldResolvers = utils_1.mapSuperFieldResolverHandlers(this.fieldResolvers, superResolver, def);
this.queries = (0, utils_1.mapSuperResolverHandlers)(this.queries, superResolver, def);
this.mutations = (0, utils_1.mapSuperResolverHandlers)(this.mutations, superResolver, def);
this.subscriptions = (0, utils_1.mapSuperResolverHandlers)(this.subscriptions, superResolver, def);
this.fieldResolvers = (0, utils_1.mapSuperFieldResolverHandlers)(this.fieldResolvers, superResolver, def);
}

@@ -246,0 +245,0 @@ superResolver = Object.getPrototypeOf(superResolver);

@@ -24,3 +24,3 @@ "use strict";

...metadata,
getObjectType: isThrowing_1.isThrowing(metadata.getObjectType)
getObjectType: (0, isThrowing_1.isThrowing)(metadata.getObjectType)
? resolverMetadata.getObjectType

@@ -27,0 +27,0 @@ : metadata.getObjectType,

@@ -8,6 +8,6 @@ "use strict";

function getInputType(target) {
return getMetadataStorage_1.getMetadataStorage().inputTypes.find(t => t.target === target);
return (0, getMetadataStorage_1.getMetadataStorage)().inputTypes.find(t => t.target === target);
}
function getArgsType(target) {
return getMetadataStorage_1.getMetadataStorage().argumentTypes.find(t => t.target === target);
return (0, getMetadataStorage_1.getMetadataStorage)().argumentTypes.find(t => t.target === target);
}

@@ -58,2 +58,6 @@ function generateInstanceTransformationTree(target) {

}
if (Array.isArray(data)) {
// recursively convert nested arrays
return data.map(it => convertToInput(tree, it));
}
const inputFields = tree.getFields().reduce((fields, field) => {

@@ -65,3 +69,3 @@ const siblings = field.fields;

if (value === null || !siblings) {
fields[field.name] = types_1.convertToType(field.target, value);
fields[field.name] = (0, types_1.convertToType)(field.target, value);
}

@@ -77,3 +81,3 @@ else if (Array.isArray(value)) {

}, {});
return types_1.convertToType(tree.target, inputFields);
return (0, types_1.convertToType)(tree.target, inputFields);
}

@@ -84,3 +88,3 @@ function convertValueToInstance(target, value) {

? convertToInput(transformationTree, value)
: types_1.convertToType(target, value);
: (0, types_1.convertToType)(target, value);
}

@@ -119,3 +123,3 @@ function convertValuesToInstances(target, value) {

}, {});
return types_1.convertToType(ArgsClass, transformedFields);
return (0, types_1.convertToType)(ArgsClass, transformedFields);
}

@@ -122,0 +126,0 @@ exports.convertArgsToInstance = convertArgsToInstance;

import { GraphQLFieldResolver } from "graphql";
import { FieldResolverMetadata, FieldMetadata, BaseResolverMetadata } from "../metadata/definitions";
import { IOCContainer } from "../utils/container";
export declare function createHandlerResolver(resolverMetadata: BaseResolverMetadata): GraphQLFieldResolver<any, any, any>;
export declare function createAdvancedFieldResolver(fieldResolverMetadata: FieldResolverMetadata): GraphQLFieldResolver<any, any, any>;
export declare function createBasicFieldResolver(fieldMetadata: FieldMetadata): GraphQLFieldResolver<any, any, any>;
export declare function wrapResolverWithAuthChecker(resolver: GraphQLFieldResolver<any, any>, roles: any[] | undefined): GraphQLFieldResolver<any, any>;
export declare function wrapResolverWithAuthChecker(resolver: GraphQLFieldResolver<any, any>, container: IOCContainer, roles: any[] | undefined): GraphQLFieldResolver<any, any>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapResolverWithAuthChecker = exports.createBasicFieldResolver = exports.createAdvancedFieldResolver = exports.createHandlerResolver = void 0;
const tslib_1 = require("tslib");
const helpers_1 = require("./helpers");
const types_1 = require("../helpers/types");
const build_context_1 = require("../schema/build-context");
const isPromiseLike_1 = require("../utils/isPromiseLike");
const isPromiseLike_1 = (0, tslib_1.__importDefault)(require("../utils/isPromiseLike"));
const auth_middleware_1 = require("../helpers/auth-middleware");

@@ -12,10 +13,10 @@ function createHandlerResolver(resolverMetadata) {

const middlewares = globalMiddlewares.concat(resolverMetadata.middlewares);
helpers_1.applyAuthChecker(middlewares, authMode, authChecker, resolverMetadata.roles);
(0, helpers_1.applyAuthChecker)(middlewares, authChecker, container, authMode, resolverMetadata.roles);
return (root, args, context, info) => {
const resolverData = { root, args, context, info };
const targetInstanceOrPromise = container.getInstance(resolverMetadata.target, resolverData);
if (isPromiseLike_1.default(targetInstanceOrPromise)) {
return targetInstanceOrPromise.then(targetInstance => helpers_1.applyMiddlewares(container, resolverData, middlewares, () => {
const params = helpers_1.getParams(resolverMetadata.params, resolverData, globalValidate, pubSub);
if (isPromiseLike_1.default(params)) {
if ((0, isPromiseLike_1.default)(targetInstanceOrPromise)) {
return targetInstanceOrPromise.then(targetInstance => (0, helpers_1.applyMiddlewares)(container, resolverData, middlewares, () => {
const params = (0, helpers_1.getParams)(resolverMetadata.params, resolverData, globalValidate, pubSub);
if ((0, isPromiseLike_1.default)(params)) {
return params.then(resolvedParams => targetInstance[resolverMetadata.methodName].apply(targetInstance, resolvedParams));

@@ -28,6 +29,6 @@ }

}
return helpers_1.applyMiddlewares(container, resolverData, middlewares, () => {
const params = helpers_1.getParams(resolverMetadata.params, resolverData, globalValidate, pubSub);
return (0, helpers_1.applyMiddlewares)(container, resolverData, middlewares, () => {
const params = (0, helpers_1.getParams)(resolverMetadata.params, resolverData, globalValidate, pubSub);
const targetInstance = targetInstanceOrPromise;
if (isPromiseLike_1.default(params)) {
if ((0, isPromiseLike_1.default)(params)) {
return params.then(resolvedParams => targetInstance[resolverMetadata.methodName].apply(targetInstance, resolvedParams));

@@ -49,7 +50,7 @@ }

const middlewares = globalMiddlewares.concat(fieldResolverMetadata.middlewares);
helpers_1.applyAuthChecker(middlewares, authMode, authChecker, fieldResolverMetadata.roles);
(0, helpers_1.applyAuthChecker)(middlewares, authChecker, container, authMode, fieldResolverMetadata.roles);
return (root, args, context, info) => {
const resolverData = { root, args, context, info };
const targetInstance = types_1.convertToType(targetType, root);
return helpers_1.applyMiddlewares(container, resolverData, middlewares, () => {
const targetInstance = (0, types_1.convertToType)(targetType, root);
return (0, helpers_1.applyMiddlewares)(container, resolverData, middlewares, () => {
const handlerOrGetterValue = targetInstance[fieldResolverMetadata.methodName];

@@ -61,4 +62,4 @@ if (typeof handlerOrGetterValue !== "function") {

// method
const params = helpers_1.getParams(fieldResolverMetadata.params, resolverData, globalValidate, pubSub);
if (isPromiseLike_1.default(params)) {
const params = (0, helpers_1.getParams)(fieldResolverMetadata.params, resolverData, globalValidate, pubSub);
if ((0, isPromiseLike_1.default)(params)) {
return params.then(resolvedParams => handlerOrGetterValue.apply(targetInstance, resolvedParams));

@@ -76,10 +77,10 @@ }

const middlewares = globalMiddlewares.concat(fieldMetadata.middlewares);
helpers_1.applyAuthChecker(middlewares, authMode, authChecker, fieldMetadata.roles);
(0, helpers_1.applyAuthChecker)(middlewares, authChecker, container, authMode, fieldMetadata.roles);
return (root, args, context, info) => {
const resolverData = { root, args, context, info };
return helpers_1.applyMiddlewares(container, resolverData, middlewares, () => root[fieldMetadata.name]);
return (0, helpers_1.applyMiddlewares)(container, resolverData, middlewares, () => root[fieldMetadata.name]);
};
}
exports.createBasicFieldResolver = createBasicFieldResolver;
function wrapResolverWithAuthChecker(resolver, roles) {
function wrapResolverWithAuthChecker(resolver, container, roles) {
const { authChecker, authMode } = build_context_1.BuildContext;

@@ -91,5 +92,5 @@ if (!authChecker || !roles) {

const resolverData = { root, args, context, info };
return auth_middleware_1.AuthMiddleware(authChecker, authMode, roles)(resolverData, async () => resolver(root, args, context, info));
return (0, auth_middleware_1.AuthMiddleware)(authChecker, container, authMode, roles)(resolverData, async () => resolver(root, args, context, info));
};
}
exports.wrapResolverWithAuthChecker = wrapResolverWithAuthChecker;

@@ -8,3 +8,3 @@ import { PubSubEngine } from "graphql-subscriptions";

export declare function getParams(params: ParamMetadata[], resolverData: ResolverData<any>, globalValidate: ValidateSettings, pubSub: PubSubEngine): Promise<any[]> | any[];
export declare function applyAuthChecker(middlewares: Array<Middleware<any>>, authMode: AuthMode, authChecker?: AuthChecker<any, any>, roles?: any[]): void;
export declare function applyAuthChecker(middlewares: Array<Middleware<any>>, authChecker: AuthChecker<any, any> | undefined, container: IOCContainer, authMode: AuthMode, roles: any[] | undefined): void;
export declare function applyMiddlewares(container: IOCContainer, resolverData: ResolverData<any>, middlewares: Array<Middleware<any>>, resolverHandlerFunction: () => any): Promise<any>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyMiddlewares = exports.applyAuthChecker = exports.getParams = void 0;
const tslib_1 = require("tslib");
const types_1 = require("../helpers/types");

@@ -8,3 +9,3 @@ const validate_arg_1 = require("./validate-arg");

const convert_args_1 = require("./convert-args");
const isPromiseLike_1 = require("../utils/isPromiseLike");
const isPromiseLike_1 = (0, tslib_1.__importDefault)(require("../utils/isPromiseLike"));
function getParams(params, resolverData, globalValidate, pubSub) {

@@ -16,5 +17,5 @@ const paramValues = params

case "args":
return validate_arg_1.validateArg(convert_args_1.convertArgsToInstance(paramInfo, resolverData.args), paramInfo.getType(), globalValidate, paramInfo.validate);
return (0, validate_arg_1.validateArg)((0, convert_args_1.convertArgsToInstance)(paramInfo, resolverData.args), paramInfo.getType(), globalValidate, paramInfo.validate);
case "arg":
return validate_arg_1.validateArg(convert_args_1.convertArgToInstance(paramInfo, resolverData.args), paramInfo.getType(), globalValidate, paramInfo.validate);
return (0, validate_arg_1.validateArg)((0, convert_args_1.convertArgToInstance)(paramInfo, resolverData.args), paramInfo.getType(), globalValidate, paramInfo.validate);
case "context":

@@ -32,3 +33,3 @@ if (paramInfo.propertyName) {

}
return types_1.convertToType(paramInfo.getType(), rootValue);
return (0, types_1.convertToType)(paramInfo.getType(), rootValue);
case "info":

@@ -53,5 +54,5 @@ return resolverData.info;

exports.getParams = getParams;
function applyAuthChecker(middlewares, authMode, authChecker, roles) {
function applyAuthChecker(middlewares, authChecker, container, authMode, roles) {
if (authChecker && roles) {
middlewares.unshift(auth_middleware_1.AuthMiddleware(authChecker, authMode, roles));
middlewares.unshift((0, auth_middleware_1.AuthMiddleware)(authChecker, container, authMode, roles));
}

@@ -58,0 +59,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -18,3 +37,3 @@ exports.validateArg = void 0;

}
const { validateOrReject } = await Promise.resolve().then(() => require("class-validator"));
const { validateOrReject } = await Promise.resolve().then(() => __importStar(require("class-validator")));
try {

@@ -21,0 +40,0 @@ if (Array.isArray(argValue)) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./aliases"), exports);
tslib_1.__exportStar(require("./isodate"), exports);
tslib_1.__exportStar(require("./timestamp"), exports);
(0, tslib_1.__exportStar)(require("./aliases"), exports);
(0, tslib_1.__exportStar)(require("./isodate"), exports);
(0, tslib_1.__exportStar)(require("./timestamp"), exports);

@@ -32,2 +32,6 @@ import { GraphQLScalarType } from "graphql";

nullableByDefault?: boolean;
/**
* Disable inferring default values from property initializers, like `created = new Date();`
*/
disableInferringDefaultValues?: boolean;
}

@@ -44,2 +48,3 @@ export declare abstract class BuildContext {

static nullableByDefault: boolean;
static disableInferringDefaultValues: boolean;
/**

@@ -46,0 +51,0 @@ * Set static fields with current building context data

@@ -37,6 +37,9 @@ "use strict";

}
this.container = new container_1.IOCContainer(options.container);
if (options.nullableByDefault !== undefined) {
this.nullableByDefault = options.nullableByDefault;
}
if (options.disableInferringDefaultValues !== undefined) {
this.disableInferringDefaultValues = options.disableInferringDefaultValues;
}
this.container = new container_1.IOCContainer(options.container);
}

@@ -56,2 +59,3 @@ /**

this.nullableByDefault = false;
this.disableInferringDefaultValues = false;
}

@@ -58,0 +62,0 @@ }

@@ -1,2 +0,2 @@

import { ObjectTypeDefinitionNode, InputObjectTypeDefinitionNode, GraphQLOutputType, FieldDefinitionNode, GraphQLInputType, InputValueDefinitionNode, DirectiveNode } from "graphql";
import { ObjectTypeDefinitionNode, InputObjectTypeDefinitionNode, GraphQLOutputType, FieldDefinitionNode, GraphQLInputType, InputValueDefinitionNode, DirectiveNode, InterfaceTypeDefinitionNode } from "graphql";
import { DirectiveMetadata } from "../metadata/definitions";

@@ -7,2 +7,3 @@ export declare function getObjectTypeDefinitionNode(name: string, directiveMetadata?: DirectiveMetadata[]): ObjectTypeDefinitionNode | undefined;

export declare function getInputValueDefinitionNode(name: string, type: GraphQLInputType, directiveMetadata?: DirectiveMetadata[]): InputValueDefinitionNode | undefined;
export declare function getInterfaceTypeDefinitionNode(name: string, directiveMetadata?: DirectiveMetadata[]): InterfaceTypeDefinitionNode | undefined;
export declare function getDirectiveNode(directive: DirectiveMetadata): DirectiveNode;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDirectiveNode = exports.getInputValueDefinitionNode = exports.getFieldDefinitionNode = exports.getInputObjectTypeDefinitionNode = exports.getObjectTypeDefinitionNode = void 0;
exports.getDirectiveNode = exports.getInterfaceTypeDefinitionNode = exports.getInputValueDefinitionNode = exports.getFieldDefinitionNode = exports.getInputObjectTypeDefinitionNode = exports.getObjectTypeDefinitionNode = void 0;
const graphql_1 = require("graphql");

@@ -78,2 +78,17 @@ const errors_1 = require("../errors");

exports.getInputValueDefinitionNode = getInputValueDefinitionNode;
function getInterfaceTypeDefinitionNode(name, directiveMetadata) {
if (!directiveMetadata || !directiveMetadata.length) {
return;
}
return {
kind: "InterfaceTypeDefinition",
name: {
kind: "Name",
// FIXME: use proper AST representation
value: name,
},
directives: directiveMetadata.map(getDirectiveNode),
};
}
exports.getInterfaceTypeDefinitionNode = getInterfaceTypeDefinitionNode;
function getDirectiveNode(directive) {

@@ -97,3 +112,3 @@ const { nameOrDefinition, args } = directive;

},
value: graphql_1.parseValue(args[argKey]),
value: (0, graphql_1.parseValue)(args[argKey]),
})),

@@ -104,3 +119,3 @@ };

try {
parsed = graphql_1.parse(`type String ${nameOrDefinition}`);
parsed = (0, graphql_1.parse)(`type String ${nameOrDefinition}`);
}

@@ -107,0 +122,0 @@ catch (err) {

@@ -18,3 +18,3 @@ "use strict";

if (!options.skipCheck) {
const { errors } = await graphql_1.graphql(schema, graphql_1.getIntrospectionQuery());
const { errors } = await (0, graphql_1.graphql)(schema, (0, graphql_1.getIntrospectionQuery)());
if (errors) {

@@ -29,3 +29,3 @@ throw new errors_1.GeneratingSchemaError(errors);

build_context_1.BuildContext.create(options);
getMetadataStorage_1.getMetadataStorage().build(options);
(0, getMetadataStorage_1.getMetadataStorage)().build(options);
this.buildTypesInfo(options.resolvers);

@@ -49,4 +49,4 @@ const orphanedTypes = options.orphanedTypes || (options.resolvers ? [] : undefined);

static checkForErrors(options) {
graphql_version_1.ensureInstalledCorrectGraphQLPackage();
if (getMetadataStorage_1.getMetadataStorage().authorizedFields.length !== 0 && options.authChecker === undefined) {
(0, graphql_version_1.ensureInstalledCorrectGraphQLPackage)();
if ((0, getMetadataStorage_1.getMetadataStorage)().authorizedFields.length !== 0 && options.authChecker === undefined) {
throw new Error("You need to provide `authChecker` function for `@Authorized` decorator usage!");

@@ -56,2 +56,6 @@ }

static getDefaultValue(typeInstance, typeOptions, fieldName, typeName) {
const { disableInferringDefaultValues } = build_context_1.BuildContext;
if (disableInferringDefaultValues) {
return typeOptions.defaultValue;
}
const defaultValueFromInitializer = typeInstance[fieldName];

@@ -68,3 +72,3 @@ if (typeOptions.defaultValue !== undefined &&

static buildTypesInfo(resolvers) {
this.unionTypesInfo = getMetadataStorage_1.getMetadataStorage().unions.map(unionMetadata => {
this.unionTypesInfo = (0, getMetadataStorage_1.getMetadataStorage)().unions.map(unionMetadata => {
// use closure to capture values from this selected schema build

@@ -98,3 +102,3 @@ const unionObjectTypesInfo = [];

const objectTypeInfo = unionObjectTypesInfo.find(type => type.target === instanceTarget);
return objectTypeInfo.type;
return objectTypeInfo === null || objectTypeInfo === void 0 ? void 0 : objectTypeInfo.type.name;
},

@@ -104,4 +108,4 @@ }),

});
this.enumTypesInfo = getMetadataStorage_1.getMetadataStorage().enums.map(enumMetadata => {
const enumMap = types_1.getEnumValuesMap(enumMetadata.enumObj);
this.enumTypesInfo = (0, getMetadataStorage_1.getMetadataStorage)().enums.map(enumMetadata => {
const enumMap = (0, types_1.getEnumValuesMap)(enumMetadata.enumObj);
return {

@@ -124,3 +128,3 @@ enumObj: enumMetadata.enumObj,

});
this.objectTypesInfo = getMetadataStorage_1.getMetadataStorage().objectTypes.map(objectType => {
this.objectTypesInfo = (0, getMetadataStorage_1.getMetadataStorage)().objectTypes.map(objectType => {
const objectSuperClass = Object.getPrototypeOf(objectType.target);

@@ -140,3 +144,3 @@ const hasExtended = objectSuperClass.prototype !== undefined;

description: objectType.description,
astNode: definition_node_1.getObjectTypeDefinitionNode(objectType.name, objectType.directives),
astNode: (0, definition_node_1.getObjectTypeDefinitionNode)(objectType.name, objectType.directives),
extensions: objectType.extensions,

@@ -168,3 +172,3 @@ interfaces: () => {

if (objectType.interfaceClasses) {
const implementedInterfaces = getMetadataStorage_1.getMetadataStorage().interfaceTypes.filter(it => objectType.interfaceClasses.includes(it.target));
const implementedInterfaces = (0, getMetadataStorage_1.getMetadataStorage)().interfaceTypes.filter(it => objectType.interfaceClasses.includes(it.target));
implementedInterfaces.forEach(it => {

@@ -177,3 +181,3 @@ fieldsMetadata.push(...(it.fields || []));

let fields = fieldsMetadata.reduce((fieldsMap, field) => {
const fieldResolvers = getMetadataStorage_1.getMetadataStorage().fieldResolvers;
const fieldResolvers = (0, getMetadataStorage_1.getMetadataStorage)().fieldResolvers;
const filteredFieldResolversMetadata = !resolvers

@@ -196,12 +200,13 @@ ? fieldResolvers

resolve: fieldResolverMetadata
? create_1.createAdvancedFieldResolver(fieldResolverMetadata)
? (0, create_1.createAdvancedFieldResolver)(fieldResolverMetadata)
: isSimpleResolver
? undefined
: create_1.createBasicFieldResolver(field),
: (0, create_1.createBasicFieldResolver)(field),
description: field.description,
deprecationReason: field.deprecationReason,
astNode: definition_node_1.getFieldDefinitionNode(field.name, type, field.directives),
astNode: (0, definition_node_1.getFieldDefinitionNode)(field.name, type, field.directives),
extensions: {
complexity: field.complexity,
...field.extensions,
...fieldResolverMetadata === null || fieldResolverMetadata === void 0 ? void 0 : fieldResolverMetadata.extensions,
},

@@ -215,3 +220,3 @@ };

if (superClass) {
const superClassFields = utils_1.getFieldMetadataFromObjectType(superClass);
const superClassFields = (0, utils_1.getFieldMetadataFromObjectType)(superClass);
fields = Object.assign({}, superClassFields, fields);

@@ -225,3 +230,3 @@ }

});
this.interfaceTypesInfo = getMetadataStorage_1.getMetadataStorage().interfaceTypes.map(interfaceType => {
this.interfaceTypesInfo = (0, getMetadataStorage_1.getMetadataStorage)().interfaceTypes.map(interfaceType => {
const interfaceSuperClass = Object.getPrototypeOf(interfaceType.target);

@@ -234,3 +239,3 @@ const hasExtended = interfaceSuperClass.prototype !== undefined;

// fetch ahead the subset of object types that implements this interface
const implementingObjectTypesTargets = getMetadataStorage_1.getMetadataStorage()
const implementingObjectTypesTargets = (0, getMetadataStorage_1.getMetadataStorage)()
.objectTypes.filter(objectType => objectType.interfaceClasses &&

@@ -247,2 +252,3 @@ objectType.interfaceClasses.includes(interfaceType.target))

description: interfaceType.description,
astNode: (0, definition_node_1.getInterfaceTypeDefinitionNode)(interfaceType.name, interfaceType.directives),
interfaces: () => {

@@ -265,3 +271,3 @@ let interfaces = (interfaceType.interfaceClasses || []).map(interfaceClass => this.interfaceTypesInfo.find(info => info.target === interfaceClass).type);

if (interfaceType.interfaceClasses) {
const implementedInterfacesMetadata = getMetadataStorage_1.getMetadataStorage().interfaceTypes.filter(it => interfaceType.interfaceClasses.includes(it.target));
const implementedInterfacesMetadata = (0, getMetadataStorage_1.getMetadataStorage)().interfaceTypes.filter(it => interfaceType.interfaceClasses.includes(it.target));
implementedInterfacesMetadata.forEach(it => {

@@ -274,14 +280,16 @@ fieldsMetadata.push(...(it.fields || []));

let fields = fieldsMetadata.reduce((fieldsMap, field) => {
const fieldResolverMetadata = getMetadataStorage_1.getMetadataStorage().fieldResolvers.find(resolver => resolver.getObjectType() === field.target &&
const fieldResolverMetadata = (0, getMetadataStorage_1.getMetadataStorage)().fieldResolvers.find(resolver => resolver.getObjectType() === field.target &&
resolver.methodName === field.name &&
(resolver.resolverClassMetadata === undefined ||
resolver.resolverClassMetadata.isAbstract === false));
const type = this.getGraphQLOutputType(field.target, field.name, field.getType(), field.typeOptions);
fieldsMap[field.schemaName] = {
type: this.getGraphQLOutputType(field.target, field.name, field.getType(), field.typeOptions),
type,
args: this.generateHandlerArgs(field.target, field.name, field.params),
resolve: fieldResolverMetadata
? create_1.createAdvancedFieldResolver(fieldResolverMetadata)
: create_1.createBasicFieldResolver(field),
? (0, create_1.createAdvancedFieldResolver)(fieldResolverMetadata)
: (0, create_1.createBasicFieldResolver)(field),
description: field.description,
deprecationReason: field.deprecationReason,
astNode: (0, definition_node_1.getFieldDefinitionNode)(field.name, type, field.directives),
extensions: {

@@ -298,3 +306,3 @@ complexity: field.complexity,

if (superClass) {
const superClassFields = utils_1.getFieldMetadataFromObjectType(superClass);
const superClassFields = (0, utils_1.getFieldMetadataFromObjectType)(superClass);
fields = Object.assign({}, superClassFields, fields);

@@ -313,3 +321,3 @@ }

const objectTypeInfo = implementingObjectTypesInfo.find(type => type.target === typeTarget);
return objectTypeInfo.type;
return objectTypeInfo === null || objectTypeInfo === void 0 ? void 0 : objectTypeInfo.type.name;
},

@@ -319,3 +327,3 @@ }),

});
this.inputTypesInfo = getMetadataStorage_1.getMetadataStorage().inputTypes.map(inputType => {
this.inputTypesInfo = (0, getMetadataStorage_1.getMetadataStorage)().inputTypes.map(inputType => {
const objectSuperClass = Object.getPrototypeOf(inputType.target);

@@ -336,10 +344,14 @@ const getSuperClassType = () => {

let fields = inputType.fields.reduce((fieldsMap, field) => {
field.typeOptions.defaultValue = this.getDefaultValue(inputInstance, field.typeOptions, field.name, inputType.name);
const type = this.getGraphQLInputType(field.target, field.name, field.getType(), field.typeOptions);
fieldsMap[field.schemaName] = {
const defaultValue = this.getDefaultValue(inputInstance, field.typeOptions, field.name, inputType.name);
const type = this.getGraphQLInputType(field.target, field.name, field.getType(), {
...field.typeOptions,
defaultValue,
});
fieldsMap[field.name] = {
description: field.description,
type,
defaultValue: field.typeOptions.defaultValue,
astNode: definition_node_1.getInputValueDefinitionNode(field.name, type, field.directives),
defaultValue,
astNode: (0, definition_node_1.getInputValueDefinitionNode)(field.name, type, field.directives),
extensions: field.extensions,
deprecationReason: field.deprecationReason,
};

@@ -352,3 +364,3 @@ return fieldsMap;

if (superClass) {
const superClassFields = utils_1.getFieldMetadataFromInputType(superClass);
const superClassFields = (0, utils_1.getFieldMetadataFromInputType)(superClass);
fields = Object.assign({}, superClassFields, fields);

@@ -359,3 +371,3 @@ }

},
astNode: definition_node_1.getInputObjectTypeDefinitionNode(inputType.name, inputType.directives),
astNode: (0, definition_node_1.getInputObjectTypeDefinitionNode)(inputType.name, inputType.directives),
}),

@@ -366,3 +378,3 @@ };

static buildRootQueryType(resolvers) {
const queriesHandlers = this.filterHandlersByResolvers(getMetadataStorage_1.getMetadataStorage().queries, resolvers);
const queriesHandlers = this.filterHandlersByResolvers((0, getMetadataStorage_1.getMetadataStorage)().queries, resolvers);
return new graphql_1.GraphQLObjectType({

@@ -374,3 +386,3 @@ name: "Query",

static buildRootMutationType(resolvers) {
const mutationsHandlers = this.filterHandlersByResolvers(getMetadataStorage_1.getMetadataStorage().mutations, resolvers);
const mutationsHandlers = this.filterHandlersByResolvers((0, getMetadataStorage_1.getMetadataStorage)().mutations, resolvers);
if (mutationsHandlers.length === 0) {

@@ -385,3 +397,3 @@ return;

static buildRootSubscriptionType(resolvers) {
const subscriptionsHandlers = this.filterHandlersByResolvers(getMetadataStorage_1.getMetadataStorage().subscriptions, resolvers);
const subscriptionsHandlers = this.filterHandlersByResolvers((0, getMetadataStorage_1.getMetadataStorage)().subscriptions, resolvers);
if (subscriptionsHandlers.length === 0) {

@@ -396,15 +408,18 @@ return;

static buildOtherTypes(orphanedTypes) {
const autoRegisteredObjectTypesInfo = this.objectTypesInfo.filter(typeInfo => { var _a; return (_a = typeInfo.metadata.interfaceClasses) === null || _a === void 0 ? void 0 : _a.some(interfaceClass => {
const implementedInterfaceInfo = this.interfaceTypesInfo.find(it => it.target === interfaceClass);
if (!implementedInterfaceInfo) {
return false;
}
if (implementedInterfaceInfo.metadata.autoRegisteringDisabled) {
return false;
}
if (!this.usedInterfaceTypes.has(interfaceClass)) {
return false;
}
return true;
}); });
const autoRegisteredObjectTypesInfo = this.objectTypesInfo.filter(typeInfo => {
var _a;
return (_a = typeInfo.metadata.interfaceClasses) === null || _a === void 0 ? void 0 : _a.some(interfaceClass => {
const implementedInterfaceInfo = this.interfaceTypesInfo.find(it => it.target === interfaceClass);
if (!implementedInterfaceInfo) {
return false;
}
if (implementedInterfaceInfo.metadata.autoRegisteringDisabled) {
return false;
}
if (!this.usedInterfaceTypes.has(interfaceClass)) {
return false;
}
return true;
});
});
return [

@@ -427,6 +442,6 @@ ...this.filterTypesInfoByIsAbstractAndOrphanedTypesAndExtractType(this.objectTypesInfo, orphanedTypes),

args: this.generateHandlerArgs(handler.target, handler.methodName, handler.params),
resolve: create_1.createHandlerResolver(handler),
resolve: (0, create_1.createHandlerResolver)(handler),
description: handler.description,
deprecationReason: handler.deprecationReason,
astNode: definition_node_1.getFieldDefinitionNode(handler.schemaName, type, handler.directives),
astNode: (0, definition_node_1.getFieldDefinitionNode)(handler.schemaName, type, handler.directives),
extensions: {

@@ -441,3 +456,3 @@ complexity: handler.complexity,

static generateSubscriptionsFields(subscriptionsHandlers) {
const { pubSub } = build_context_1.BuildContext;
const { pubSub, container } = build_context_1.BuildContext;
const basicFields = this.generateHandlerFields(subscriptionsHandlers);

@@ -471,3 +486,3 @@ return subscriptionsHandlers.reduce((fields, handler) => {

subscribeFn = handler.filter
? graphql_subscriptions_1.withFilter(pubSubIterator, (payload, args, context, info) => {
? (0, graphql_subscriptions_1.withFilter)(pubSubIterator, (payload, args, context, info) => {
const resolverFilterData = { payload, args, context, info };

@@ -478,3 +493,3 @@ return handler.filter(resolverFilterData);

}
fields[handler.schemaName].subscribe = create_1.wrapResolverWithAuthChecker(subscribeFn, handler.roles);
fields[handler.schemaName].subscribe = (0, create_1.wrapResolverWithAuthChecker)(subscribeFn, container, handler.roles);
return fields;

@@ -490,6 +505,7 @@ }, basicFields);

defaultValue: param.typeOptions.defaultValue,
deprecationReason: param.deprecationReason,
};
}
else if (param.kind === "args") {
const argumentType = getMetadataStorage_1.getMetadataStorage().argumentTypes.find(it => it.target === param.getType());
const argumentType = (0, getMetadataStorage_1.getMetadataStorage)().argumentTypes.find(it => it.target === param.getType());
if (!argumentType) {

@@ -501,3 +517,3 @@ throw new Error(`The value used as a type of '@Args' for '${propertyName}' of '${target.name}' ` +

while (superClass.prototype !== undefined) {
const superArgumentType = getMetadataStorage_1.getMetadataStorage().argumentTypes.find(it => it.target === superClass);
const superArgumentType = (0, getMetadataStorage_1.getMetadataStorage)().argumentTypes.find(it => it.target === superClass);
if (superArgumentType) {

@@ -516,7 +532,11 @@ this.mapArgFields(superArgumentType, args);

argumentType.fields.forEach(field => {
field.typeOptions.defaultValue = this.getDefaultValue(argumentInstance, field.typeOptions, field.name, argumentType.name);
const defaultValue = this.getDefaultValue(argumentInstance, field.typeOptions, field.name, argumentType.name);
args[field.schemaName] = {
description: field.description,
type: this.getGraphQLInputType(field.target, field.name, field.getType(), field.typeOptions),
defaultValue: field.typeOptions.defaultValue,
type: this.getGraphQLInputType(field.target, field.name, field.getType(), {
...field.typeOptions,
defaultValue,
}),
defaultValue,
deprecationReason: field.deprecationReason,
};

@@ -527,3 +547,3 @@ });

let gqlType;
gqlType = types_1.convertTypeIfScalar(type);
gqlType = (0, types_1.convertTypeIfScalar)(type);
if (!gqlType) {

@@ -558,7 +578,7 @@ const objectType = this.objectTypesInfo.find(it => it.target === type);

const { nullableByDefault } = build_context_1.BuildContext;
return types_1.wrapWithTypeOptions(target, propertyName, gqlType, typeOptions, nullableByDefault);
return (0, types_1.wrapWithTypeOptions)(target, propertyName, gqlType, typeOptions, nullableByDefault);
}
static getGraphQLInputType(target, propertyName, type, typeOptions = {}, parameterIndex, argName) {
let gqlType;
gqlType = types_1.convertTypeIfScalar(type);
gqlType = (0, types_1.convertTypeIfScalar)(type);
if (!gqlType) {

@@ -580,3 +600,3 @@ const inputType = this.inputTypesInfo.find(it => it.target === type);

const { nullableByDefault } = build_context_1.BuildContext;
return types_1.wrapWithTypeOptions(target, propertyName, gqlType, typeOptions, nullableByDefault);
return (0, types_1.wrapWithTypeOptions)(target, propertyName, gqlType, typeOptions, nullableByDefault);
}

@@ -590,3 +610,3 @@ static getResolveTypeFunction(resolveType, possibleObjectTypesInfo) {

}
return (_a = possibleObjectTypesInfo.find(objectType => objectType.target === resolvedType)) === null || _a === void 0 ? void 0 : _a.type;
return (_a = possibleObjectTypesInfo.find(objectType => objectType.target === resolvedType)) === null || _a === void 0 ? void 0 : _a.type.name;
};

@@ -593,0 +613,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildSchemaSync = exports.buildSchema = void 0;
const path = require("path");
const tslib_1 = require("tslib");
const path_1 = (0, tslib_1.__importDefault)(require("path"));
const schema_generator_1 = require("../schema/schema-generator");

@@ -13,3 +14,3 @@ const loadResolversFromGlob_1 = require("../helpers/loadResolversFromGlob");

const { schemaFileName, printSchemaOptions } = getEmitSchemaDefinitionFileOptions(options);
await emitSchemaDefinitionFile_1.emitSchemaDefinitionFile(schemaFileName, schema, printSchemaOptions);
await (0, emitSchemaDefinitionFile_1.emitSchemaDefinitionFile)(schemaFileName, schema, printSchemaOptions);
}

@@ -24,3 +25,3 @@ return schema;

const { schemaFileName, printSchemaOptions } = getEmitSchemaDefinitionFileOptions(options);
emitSchemaDefinitionFile_1.emitSchemaDefinitionFileSync(schemaFileName, schema, printSchemaOptions);
(0, emitSchemaDefinitionFile_1.emitSchemaDefinitionFileSync)(schemaFileName, schema, printSchemaOptions);
}

@@ -38,3 +39,3 @@ return schema;

if (typeof resolver === "string") {
loadResolversFromGlob_1.loadResolversFromGlob(resolver);
(0, loadResolversFromGlob_1.loadResolversFromGlob)(resolver);
}

@@ -47,3 +48,3 @@ });

function getEmitSchemaDefinitionFileOptions(buildSchemaOptions) {
const defaultSchemaFilePath = path.resolve(process.cwd(), "schema.gql");
const defaultSchemaFilePath = path_1.default.resolve(process.cwd(), "schema.gql");
return {

@@ -50,0 +51,0 @@ schemaFileName: typeof buildSchemaOptions.emitSchemaFile === "string"

@@ -6,1 +6,5 @@ import { BuildSchemaOptions } from "./buildSchema";

}>;
export declare function buildTypeDefsAndResolversSync(options: BuildSchemaOptions): {
typeDefs: string;
resolvers: import("..").ResolversMap<any, any>;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildTypeDefsAndResolvers = void 0;
exports.buildTypeDefsAndResolversSync = exports.buildTypeDefsAndResolvers = void 0;
const graphql_1 = require("graphql");

@@ -8,7 +8,15 @@ const buildSchema_1 = require("./buildSchema");

async function buildTypeDefsAndResolvers(options) {
const schema = await buildSchema_1.buildSchema(options);
const typeDefs = graphql_1.printSchema(schema);
const resolvers = createResolversMap_1.createResolversMap(schema);
const schema = await (0, buildSchema_1.buildSchema)(options);
return createTypeDefsAndResolversMap(schema);
}
exports.buildTypeDefsAndResolvers = buildTypeDefsAndResolvers;
function buildTypeDefsAndResolversSync(options) {
const schema = (0, buildSchema_1.buildSchemaSync)(options);
return createTypeDefsAndResolversMap(schema);
}
exports.buildTypeDefsAndResolversSync = buildTypeDefsAndResolversSync;
function createTypeDefsAndResolversMap(schema) {
const typeDefs = (0, graphql_1.printSchema)(schema);
const resolvers = (0, createResolversMap_1.createResolversMap)(schema);
return { typeDefs, resolvers };
}
exports.buildTypeDefsAndResolvers = buildTypeDefsAndResolvers;

@@ -19,3 +19,3 @@ "use strict";

const schemaFileContent = getSchemaFileContent(schema, options);
filesystem_1.outputFileSync(schemaFilePath, schemaFileContent);
(0, filesystem_1.outputFileSync)(schemaFilePath, schemaFileContent);
}

@@ -25,8 +25,8 @@ exports.emitSchemaDefinitionFileSync = emitSchemaDefinitionFileSync;

const schemaFileContent = getSchemaFileContent(schema, options);
await filesystem_1.outputFile(schemaFilePath, schemaFileContent);
await (0, filesystem_1.outputFile)(schemaFilePath, schemaFileContent);
}
exports.emitSchemaDefinitionFile = emitSchemaDefinitionFile;
function getSchemaFileContent(schema, options) {
const schemaToEmit = options.sortedSchema ? graphql_1.lexicographicSortSchema(schema) : schema;
return generatedSchemaWarning + graphql_1.printSchema(schemaToEmit, options);
const schemaToEmit = options.sortedSchema ? (0, graphql_1.lexicographicSortSchema)(schema) : schema;
return generatedSchemaWarning + (0, graphql_1.printSchema)(schemaToEmit, options);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ensureInstalledCorrectGraphQLPackage = exports.getPeerDependencyGraphQLRequirement = exports.getInstalledGraphQLVersion = void 0;
const semVer = require("semver");
const tslib_1 = require("tslib");
const semver_1 = (0, tslib_1.__importDefault)(require("semver"));
const errors_1 = require("../errors");

@@ -19,3 +20,3 @@ function getInstalledGraphQLVersion() {

const versionRequirement = getPeerDependencyGraphQLRequirement();
if (!semVer.satisfies(installedVersion, versionRequirement)) {
if (!semver_1.default.satisfies(installedVersion, versionRequirement)) {
throw new errors_1.UnmetGraphQLPeerDependencyError();

@@ -22,0 +23,0 @@ }

export { buildSchema, buildSchemaSync, BuildSchemaOptions } from "./buildSchema";
export { buildTypeDefsAndResolvers } from "./buildTypeDefsAndResolvers";
export { buildTypeDefsAndResolvers, buildTypeDefsAndResolversSync, } from "./buildTypeDefsAndResolvers";
export { createResolversMap } from "./createResolversMap";
export { emitSchemaDefinitionFile, emitSchemaDefinitionFileSync, PrintSchemaOptions, defaultPrintSchemaOptions, } from "./emitSchemaDefinitionFile";
export { ContainerType, ContainerGetter } from "./container";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultPrintSchemaOptions = exports.emitSchemaDefinitionFileSync = exports.emitSchemaDefinitionFile = exports.createResolversMap = exports.buildTypeDefsAndResolvers = exports.buildSchemaSync = exports.buildSchema = void 0;
exports.defaultPrintSchemaOptions = exports.emitSchemaDefinitionFileSync = exports.emitSchemaDefinitionFile = exports.createResolversMap = exports.buildTypeDefsAndResolversSync = exports.buildTypeDefsAndResolvers = exports.buildSchemaSync = exports.buildSchema = void 0;
var buildSchema_1 = require("./buildSchema");

@@ -9,2 +9,3 @@ Object.defineProperty(exports, "buildSchema", { enumerable: true, get: function () { return buildSchema_1.buildSchema; } });

Object.defineProperty(exports, "buildTypeDefsAndResolvers", { enumerable: true, get: function () { return buildTypeDefsAndResolvers_1.buildTypeDefsAndResolvers; } });
Object.defineProperty(exports, "buildTypeDefsAndResolversSync", { enumerable: true, get: function () { return buildTypeDefsAndResolvers_1.buildTypeDefsAndResolversSync; } });
var createResolversMap_1 = require("./createResolversMap");

@@ -11,0 +12,0 @@ Object.defineProperty(exports, "createResolversMap", { enumerable: true, get: function () { return createResolversMap_1.createResolversMap; } });

{
"name": "type-graphql",
"version": "1.1.1",
"version": "1.2.0-rc.1",
"author": {

@@ -9,3 +9,2 @@ "name": "Michaล‚ Lytek",

"scripts": {
"dev": "node ./dev.js",
"test": "jest --verbose --coverage",

@@ -16,5 +15,4 @@ "test:ci": "jest --verbose --coverage --ci --forceExit --detectOpenHandles --runInBand",

"check:format": "prettier --check \"{src,tests,examples}/**/*.{ts,js}\" \"docs/**/*.md\"",
"check:type": "tsc --noEmit",
"//check": "npm run check:format && npm run check:type",
"check": "npm run check:type",
"check:type": "tsc --noEmit && tsc --noEmit -p ./examples/tsconfig.json",
"check": "npm run check:format && npm run check:type",
"lint": "tslint --project tsconfig.json",

@@ -28,3 +26,3 @@ "verify": "npm run check && npm run lint",

"class-validator": ">=0.12.0",
"graphql": "^15.3.0"
"graphql": "^15.5.0"
},

@@ -34,29 +32,30 @@ "dependencies": {

"@types/node": "*",
"@types/semver": "^7.3.3",
"@types/semver": "^7.3.4",
"glob": "^7.1.6",
"graphql-query-complexity": "^0.7.0",
"graphql-subscriptions": "^1.1.0",
"semver": "^7.3.2",
"tslib": "^2.0.1"
"graphql-query-complexity": "^0.7.2",
"graphql-subscriptions": "^1.2.0",
"semver": "^7.3.4",
"tslib": "^2.1.0"
},
"devDependencies": {
"@apollo/federation": "^0.20.4",
"@apollo/gateway": "^0.21.0",
"@graphql-modules/core": "^0.7.17",
"@apollo/federation": "^0.21.2",
"@apollo/gateway": "^0.23.2",
"@graphql-modules/core": "^0.7.13",
"@graphql-modules/di": "^0.7.17",
"@mikro-orm/core": "^4.0.7",
"@mikro-orm/postgresql": "^4.0.7",
"@typegoose/typegoose": "^7.4.1",
"@types/gulp": "^4.0.7",
"@mikro-orm/core": "^4.4.4",
"@mikro-orm/postgresql": "^4.4.4",
"@typegoose/typegoose": "^7.4.8",
"@types/gulp": "^4.0.8",
"@types/gulp-replace": "0.0.31",
"@types/ioredis": "^4.17.4",
"@types/jest": "^26.0.14",
"@types/mongoose": "^5.7.36",
"@types/node": "^14.11.2",
"@types/ioredis": "^4.22.0",
"@types/jest": "^26.0.20",
"@types/mongoose": "^5.10.3",
"@types/node": "^14.14.31",
"@types/rimraf": "^3.0.0",
"apollo-cache-control": "^0.11.3",
"apollo-server": "^2.18.1",
"class-validator": "^0.12.2",
"apollo-cache-control": "^0.11.6",
"apollo-server": "^2.21.0",
"apollo-server-plugin-response-cache": "^0.6.0",
"class-validator": "^0.13.1",
"del": "^6.0.0",
"graphql": "^15.3.0",
"graphql": "^15.5.0",
"graphql-redis-subscriptions": "^2.3.1",

@@ -68,21 +67,21 @@ "graphql-tag": "^2.11.0",

"gulpclass": "^0.2.0",
"husky": "^4.3.0",
"ioredis": "^4.17.3",
"jest": "^26.4.2",
"joiful": "^2.0.1",
"lint-staged": "^10.4.0",
"mongoose": "^5.10.7",
"pg": "^8.3.3",
"prettier": "^2.1.2",
"husky": "^4.3.8",
"ioredis": "^4.23.0",
"jest": "^26.6.3",
"joiful": "^3.0.0",
"lint-staged": "^10.5.4",
"mongoose": "5.10.18",
"pg": "^8.5.1",
"prettier": "^2.2.1",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"ts-jest": "^26.4.1",
"ts-node": "^9.0.0",
"ts-jest": "^26.5.2",
"ts-node": "^9.1.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-eslint-rules": "^5.4.0",
"typedi": "^0.8.0",
"typeorm": "^0.2.28",
"typeorm-typedi-extensions": "^0.2.3",
"typescript": "~4.0.3"
"typedi": "^0.10.0",
"typeorm": "^0.2.31",
"typeorm-typedi-extensions": "^0.4.1",
"typescript": "~4.2.2"
},

@@ -133,5 +132,5 @@ "husky": {

"engines": {
"node": ">= 10.3"
"node": ">= 10.13"
},
"private": false
}

@@ -6,7 +6,7 @@ ![logo](https://raw.githubusercontent.com/MichalLytek/type-graphql/master/img/logo.png)

[![npm version](https://badge.fury.io/js/type-graphql.svg)](https://badge.fury.io/js/type-graphql)
[![Build Status](https://travis-ci.com/MichalLytek/type-graphql.svg?branch=master)](https://travis-ci.com/MichalLytek/type-graphql)
[![Build Status](https://img.shields.io/github/checks-status/MichalLytek/type-graphql/master)](https://github.com/MichalLytek/type-graphql/actions/workflows/main.yml?query=branch%3Amaster)
[![codecov](https://codecov.io/gh/MichalLytek/type-graphql/branch/master/graph/badge.svg)](https://codecov.io/gh/MichalLytek/type-graphql)
[![dependencies](https://david-dm.org/MichalLytek/type-graphql/status.svg)](https://david-dm.org/MichalLytek/type-graphql)
![dependencies](https://img.shields.io/david/MichalLytek/type-graphql)
[![open collective](https://opencollective.com/typegraphql/tiers/badge.svg)](<(https://opencollective.com/typegraphql)>)
[![install size](https://packagephobia.now.sh/badge?p=type-graphql)](https://packagephobia.now.sh/result?p=type-graphql)
[![gitter](https://badges.gitter.im/type-graphql.svg)](https://gitter.im/type-graphql?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

@@ -102,15 +102,18 @@ Create GraphQL schema and resolvers with TypeScript, using classes and decorators!

```js
export const getRecipesResolver: GraphQLFieldResolver<void, Context, GetRecipesArgs> =
async (_, args, ctx) => {
// common tasks repeatable for almost every resolver
const repository = TypeORM.getRepository(Recipe);
const auth = Container.get(AuthService);
await joi.validate(getRecipesSchema, args);
if (!auth.check(ctx.user)) {
throw new NotAuthorizedError();
}
export const getRecipesResolver: GraphQLFieldResolver<void, Context, GetRecipesArgs> = async (
_,
args,
ctx,
) => {
// common tasks repeatable for almost every resolver
const repository = TypeORM.getRepository(Recipe);
const auth = Container.get(AuthService);
await joi.validate(getRecipesSchema, args);
if (!auth.check(ctx.user)) {
throw new NotAuthorizedError();
}
// our business logic, e.g.:
return repository.find({ skip: args.offset, take: args.limit });
};
// our business logic, e.g.:
return repository.find({ skip: args.offset, take: args.limit });
};
```

@@ -161,4 +164,4 @@

| [<img src="https://raw.githubusercontent.com/MichalLytek/type-graphql/master/img/blue_receipt.gif" width="450">](http://career.bluereceipt.co/) | [<img src="https://raw.githubusercontent.com/MichalLytek/type-graphql/master/img/ecad.png" width="200">](https://www.ecadlabs.com/) |
| :---: | :---: |
| [**BlueReceipt**](http://career.bluereceipt.co/) | [**ECAD Labs**](https://www.ecadlabs.com/) |
| :---------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------: |
| [**BlueReceipt**](http://career.bluereceipt.co/) | [**ECAD Labs**](https://www.ecadlabs.com/) |

@@ -169,5 +172,5 @@ > Please ask your company to support this open source project by [becoming a gold sponsor](https://opencollective.com/typegraphql/contribute/gold-sponsors-8340) and getting a premium technical support from our core contributors.

| [<img src="https://raw.githubusercontent.com/MichalLytek/type-graphql/master/img/gorrion.png" width="250">](https://gorrion.io/) | [<img src="https://raw.githubusercontent.com/MichalLytek/type-graphql/master/img/mr-yum.png" width="100">](https://www.mryum.com/) |
| :---: | :---: |
| [**Gorrion Software House**](https://gorrion.io/) | [**Mr Yum**](https://www.mryum.com/) |
| [<img src="https://raw.githubusercontent.com/MichalLytek/type-graphql/master/img/gorrion.png" width="250">](https://gorrion.io/) | [<img src="https://raw.githubusercontent.com/MichalLytek/type-graphql/master/img/chums.svg" width="125">](https://www.chums.co/) |
| :------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: |
| [**Gorrion Software House**](https://gorrion.io/) | [**Chums**](https://www.chums.co/) |

@@ -177,12 +180,15 @@ ### Bronze Sponsors ๐Ÿฅ‰

| [<img src="https://raw.githubusercontent.com/MichalLytek/type-graphql/master/img/live-graphics-system.png" width="60">](https://www.ligrsystems.com/) | [<img src="https://raw.githubusercontent.com/MichalLytek/type-graphql/master/img/lifex.png" width="75">](https://www.joinlifex.com/) | [<img src="https://raw.githubusercontent.com/MichalLytek/type-graphql/master/img/swiss-mentor.png" width="125">](https://www.swissmentor.com/) |
| :---: | :---: | :---: |
| [**Live Graphic Systems**](https://www.ligrsystems.com/) | [**LifeX Aps**](https://www.joinlifex.com/) | [**SwissMentor**](https://www.swissmentor.com/) |
| :---------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------: |
| [**Live Graphic Systems**](https://www.ligrsystems.com/) | [**LifeX Aps**](https://www.joinlifex.com/) | [**SwissMentor**](https://www.swissmentor.com/) |
[![Become a Sponsor](https://opencollective.com/static/images/become_sponsor.svg)](https://opencollective.com/typegraphql)
### Members ๐Ÿ’ช and Backers โ˜•
### Members ๐Ÿ’ช
[![](https://opencollective.com/typegraphql/sponsors.svg?width=890&button=false)](https://opencollective.com/typegraphql#contributors)
[![](https://opencollective.com/typegraphql/backers.svg?width=890&button=false)](https://opencollective.com/typegraphql#contributors)
[![](https://opencollective.com/typegraphql/tiers/members.svg?avatarHeight=48&width=890&button=false)](https://opencollective.com/typegraphql#contributors)
### Backers โ˜•
[![](https://opencollective.com/typegraphql/tiers/backers.svg?avatarHeight=48&width=890&button=false)](https://opencollective.com/typegraphql#contributors)
## Want to help?

@@ -189,0 +195,0 @@

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