MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / emit_graphql_edge

Function emit_graphql_edge

src/pipeline/pass_parallel.c:1907–1939  ·  view source on GitHub ↗

Emit GRAPHQL_CALLS edge. Extract operation from first string arg if available. */

Source from the content-addressed store, hash-verified

1905
1906/* Emit GRAPHQL_CALLS edge. Extract operation from first string arg if available. */
1907static void emit_graphql_edge(cbm_gbuf_t *gbuf, const cbm_gbuf_node_t *source, const CBMCall *call,
1908 const cbm_resolution_t *res) {
1909 const char *op = call->first_string_arg;
1910 if (!op || !op[0]) {
1911 op = call->callee_name;
1912 }
1913 /* Try to extract a query/mutation name from the operation string */
1914 char op_name[CBM_SZ_256];
1915 snprintf(op_name, sizeof(op_name), "%s", op);
1916 /* Trim leading whitespace and "query "/"mutation " prefix */
1917 const char *p = op_name;
1918 while (*p == ' ' || *p == '\t' || *p == '\n') {
1919 p++;
1920 }
1921 if (strncmp(p, "query ", CBM_SZ_6) == 0) {
1922 p += CBM_SZ_6;
1923 } else if (strncmp(p, "mutation ", CBM_SZ_8) == 0) {
1924 p += CBM_SZ_8;
1925 }
1926
1927 char route_qn[CBM_SZ_512];
1928 snprintf(route_qn, sizeof(route_qn), "__graphql__%s", p);
1929
1930 int64_t route_id =
1931 cbm_gbuf_upsert_node(gbuf, "Route", p, route_qn, "", 0, 0, "{\"source\":\"graphql\"}");
1932
1933 char esc_c[CBM_SZ_256];
1934 cbm_json_escape(esc_c, sizeof(esc_c), call->callee_name);
1935 char props[CBM_SZ_1K];
1936 snprintf(props, sizeof(props), "{\"callee\":\"%s\",\"operation\":\"%s\",\"confidence\":%.2f}",
1937 esc_c, p, res->confidence);
1938 cbm_gbuf_insert_edge(gbuf, source->id, route_id, "GRAPHQL_CALLS", props);
1939}
1940
1941/* Emit TRPC_CALLS edge. Extract procedure path from callee chain. */
1942static void emit_trpc_edge(cbm_gbuf_t *gbuf, const cbm_gbuf_node_t *source, const CBMCall *call,

Callers 1

emit_service_edgeFunction · 0.85

Calls 3

cbm_gbuf_upsert_nodeFunction · 0.85
cbm_json_escapeFunction · 0.85
cbm_gbuf_insert_edgeFunction · 0.85

Tested by

no test coverage detected