@theydo/graphql-directive-requires-authentication
Advanced tools
Comparing version 0.1.10 to 0.1.11
import { SchemaDirectiveVisitor } from 'graphql-tools'; | ||
export interface RequiresAuthenticationOptions<Context extends any> { | ||
isAuthenticated: (context: Context) => boolean | Promise<boolean>; | ||
throwError?: Error; | ||
throwError?: ((context: Context) => Error) | Error; | ||
} | ||
export default function <T extends any>(options: RequiresAuthenticationOptions<T>): typeof SchemaDirectiveVisitor; |
@@ -69,2 +69,3 @@ "use strict"; | ||
_this.resolver = function (_, _args, context) { return __awaiter(_this, void 0, void 0, function () { | ||
var formattedError; | ||
return __generator(this, function (_a) { | ||
@@ -75,2 +76,3 @@ switch (_a.label) { | ||
if (!(_a.sent())) { | ||
formattedError = typeof error === 'function' ? error(context) : error; | ||
throw error; | ||
@@ -77,0 +79,0 @@ } |
{ | ||
"name": "@theydo/graphql-directive-requires-authentication", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"description": "GraphQL directive for checking authentication through context", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
10497
136