UNPKG

@envelop/extended-validation

Version:

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

7 lines (6 loc) 285 B
export 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; }