UNPKG

@pothos/plugin-scope-auth

Version:

A Pothos plugin for adding scope based authorization checks to your GraphQL Schema

45 lines (44 loc) 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function _export(target, all) { for(var name in all)Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get }); } _export(exports, { get cacheKey () { return cacheKey; }, get canCache () { return canCache; }, get isObjectOrInterface () { return isObjectOrInterface; } }); function canCache(map) { if (map.$granted) { return false; } return (map.$all ? canCache(map.$all) : true) && (map.$any ? canCache(map.$any) : true); } function cacheKey(path) { if (!path) { // Root return '*'; } let key = String(path.key); let current = path.prev; while(current){ key = `${current.key}.${key}`; current = current.prev; } return key; } function isObjectOrInterface(fieldConfig) { return (fieldConfig.graphqlKind === 'Interface' || fieldConfig.graphqlKind === 'Object') && fieldConfig.kind !== 'Query' && fieldConfig.kind !== 'Mutation' && fieldConfig.kind !== 'Subscription'; } //# sourceMappingURL=util.js.map