@graphql-mesh/transport-rest
Version:
34 lines (33 loc) • 1.25 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDirectiveAnnotations = void 0;
const graphql_1 = require("graphql");
function getDirectiveAnnotations(directableObj) {
const directiveAnnotations = [];
const directiveExtensions = directableObj.extensions?.directives;
if (directiveExtensions) {
for (const directiveName in directiveExtensions) {
const args = directiveExtensions[directiveName];
directiveAnnotations.push({
name: directiveName,
args,
});
}
}
const directiveAstNodes = directableObj.astNode?.directives;
if (directiveAstNodes) {
for (const directiveNode of directiveAstNodes) {
const args = {};
for (const argNode of directiveNode.arguments || []) {
const argValue = (0, graphql_1.valueFromASTUntyped)(argNode.value);
args[argNode.name.value] = argValue;
directiveAnnotations.push({
name: directiveNode.name.value,
args,
});
}
}
}
return directiveAnnotations;
}
exports.getDirectiveAnnotations = getDirectiveAnnotations;
;