Fix broken JS/Java/Rust code samples in quickstart docs

Merged
SH
1d ago
+37-23

Summary

Fixes several code samples in the quickstart docs that would fail to compile/run as written, found while reviewing getting-started/index.mdx against the actual client APIs (falkordb-ts, jfalkordb, falkordb-rs).

getting-started/index.mdx

  • JavaScript: graph.query()/graph.roQuery() resolve to { headers, data, ... }, not an iterable. for (const record of result) throws result is not iterable at runtime. Now iterates result.data.
  • Java: Record has no get(...) method — only getValue(String key) / getValue(int index). Fixed record.get("Friend") → record.getValue("Friend") (and PostContent).
  • Rust:
    • Raw string literals (r#"..."#) had \" escapes around property values, which raw strings don't process — the literal backslashes would break the Cypher text sent to the server. Removed the unneeded escaping.
    • The query blocks called .execute().await? while the client was built with the synchronous FalkorClientBuilder::new() (not new_async()), which isn't awaitable. Switched to the sync API consistently (.execute().expect(...), no .await).
    • record["Friend"] indexing on a Row doesn't exist; Row only exposes .get(column) / .try_get::<T>(column). Fixed to unwrap the per-row FalkorResult and call row.try_get::<String>("Friend").

index.mdx (homepage)

  • Rust: this snippet uses the async client (FalkorClientBuilder::new_async()), so nodes.data is a RowStream implementing futures::Stream, not a synchronous Iterator. for node in nodes.data.by_ref() doesn't compile against a Stream. Replaced with while let Some(row) = nodes.data.next().await { ... } under futures::StreamExt, and unwraps each row's FalkorResult before printing.
    • Also changed graph.delete().await? to let _ = graph.delete().await; so the first run (graph doesn't exist yet) doesn't abort the script, matching the idiom used in falkordb-rs's own examples.

Verification

Checked each fix against the authoritative client sources/docs: falkordb-ts README/npm package examples, jfalkordb's Record.java/Graph.java interfaces, and falkordb-rs's Row/RowStream/QueryBuilder API docs.

Co-Authored-By: Warp agent@warp.dev


Summary by cubic

Fixes code samples in the quickstart docs so they compile and run as written against the actual client APIs.

Bug Fixes

  • JavaScript samples iterate result.data since query results come back as an object, not an iterable.
  • Java samples use Record.getValue(...) instead of the non-existent Record.get(...).
  • Rust samples drop escaped quotes inside raw string literals, use the synchronous client consistently in getting-started, and read columns with row.try_get(...) instead of indexing.
  • The homepage Rust sample drains the async RowStream with next().await and ignores the delete error on first run so the script doesn't abort.
  • Adds getValue to the spellcheck wordlist, which CI flagged in the new Java comments.

Summary by CodeRabbit

  • Documentation
    • Updated the getting-started examples to reflect current Rust, JavaScript, and Java patterns for creating graphs and querying results.
    • Rust examples demonstrate synchronous operations in the getting-started guide and asynchronous query-result processing in the main guide. The main guide’s deletion example no longer propagates graph-deletion errors.
    • JavaScript examples show how to iterate through returned rows, and Java examples clarify how to access record values.