in src/rule-unused-fields.js [21:57]
function walkAST(node, ignoreLevel) {
if (node.kind === 'Field' && !ignoreLevel) {
if (hasPrecedingEslintDisableComment(node, ESLINT_DISABLE_COMMENT)) {
return;
}
const nameNode = node.alias || node.name;
fieldNames[nameNode.value] = nameNode;
}
if (node.kind === 'OperationDefinition') {
if (
node.operation === 'mutation' ||
node.operation === 'subscription' ||
hasPrecedingEslintDisableComment(node, ESLINT_DISABLE_COMMENT)
) {
return;
}
// Ignore fields that are direct children of query as used in mutation
// or query definitions.
node.selectionSet.selections.forEach(selection => {
walkAST(selection, true);
});
return;
}
for (const prop in node) {
const value = node[prop];
if (prop === 'loc') {
continue;
}
if (value && typeof value === 'object') {
walkAST(value);
} else if (Array.isArray(value)) {
value.forEach(child => {
walkAST(child);
});
}
}
}