Skip to content

JS extractor misses property-assigned functions (api.foo = function) — factory/DI modules become near-invisible #2524

Closed

Description

Version: graphifyy 0.9.34 (pip install in a venv), Python 3.14, macOS (arm64)

Summary

The JavaScript extractor captures top-level function declarations but not function expressions assigned to object properties. Modules written in the factory / dependency-injection style — very common in Node — end up nearly empty in the graph, so queries against their symbols return "No matching nodes found."

Repro

// visible.js — extracted fine
function topLevel() { return 1; }

// factory.js — the dominant pattern in our codebase
function createApi(deps) {
  const api = {};
  api.sourceClips = async function sourceClips(topic) {   // ← not extracted
    return deps.fetch(topic);
  };
  api.renderVideo = function renderVideo(clips) {         // ← not extracted
    return clips.length;
  };
  return api;
}
module.exports = { createApi };

graphify update . on a real production backend written this way:

  • a ~1,400-line pipeline module whose entire surface is api.foo = function foo(...) inside one factory → 8 nodes (the imports, the factory shell, and two top-level helpers); none of the ~100 methods, no call edges between them
  • a sibling ~3,000-line module written with top-level function declarations → 111 nodes, edges look right

So the graph quality tracks the declaration style, and query "who calls sourceClips" / affected "sourceClips" both no-hit even though the call sites exist.

Expected

Named function expressions assigned to object properties (obj.name = function name() {}, obj.name = async function () {}, arrow equivalents) inside a factory captured as nodes — ideally namespaced like the existing module_symbol ids — with call edges resolved at least within the module.

Why it matters

The factory-with-injected-deps style is what testable Node codebases without classes tend to look like (it's why ours is written that way). Right now the token-saving story ("query the graph instead of reading the file") inverts for exactly those codebases: the better-factored the module, the less the graph sees.

Happy to test a branch against our codebase and report node/edge counts.

Activity

  1. safishamsi commented on Aug 19, 2026

    @safishamsi
    Member

    Fixed in v0.9.47: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.47. The JS/TS extractor now captures function expressions assigned to a local factory object (obj.name = function / async / arrow), namespaced under the object, with intra-factory call edges resolved. Your exact repro (createApi with api.sourceClips / api.renderVideo) now produces the method nodes and the renderVideo -> sourceClips call edge. Closing as resolved; if a variant in your codebase still comes up short, reopen with a snippet and we will take another look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions