UNPKG

@envelop/extended-validation

Version:

Extended validation plugin adds support for writing GraphQL validation rules, that has access to all `execute` parameters, including variables.

10 lines (9 loc) 414 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDirectiveFromAstNode = getDirectiveFromAstNode; function getDirectiveFromAstNode(astNode, names) { const directives = astNode.directives || []; const namesArr = Array.isArray(names) ? names : [names]; const authDirective = directives.find(d => namesArr.includes(d.name.value)); return authDirective || null; }