Build your first graph

Use the installed Linux CLI and two tiny files to map accounts and transfers, then check the result.

On this page

1. Download the sample

Finish Linux installation first. The example uses three files in one directory. It does not need a database connection.

Shell
demo_dir=$(mktemp -d)
cd "$demo_dir"
demo_base=https://graphlake-docs.pages.dev/assets/examples/transfer
curl -fLO "$demo_base/graph.yaml"
curl -fLO "$demo_base/accounts.csv"
curl -fLO "$demo_base/transfers.jsonl"

2. Read the mapping

files resolves relative to graph.yaml. The file schemas assign Int64 to keys and endpoints and Decimal128(18, 2) to amounts. The CSV columns follow the header order.

View the complete graph.yaml
YAML
graph: text-files
sources:
  people:
    type: csv
    tables:
      accounts:
        files: [accounts.csv]
        columns:
          - {name: id, data_type: Int64, nullable: false}
          - {name: name, data_type: Utf8}
  payments:
    type: jsonl
    tables:
      transfers:
        files: [transfers.jsonl]
        columns:
          - {name: id, data_type: Int64, nullable: false}
          - {name: src, data_type: Int64}
          - {name: dst, data_type: Int64}
          - {name: amount, data_type: 'Decimal128(18, 2)'}
nodes:
  Account: {source: people.accounts, key: [id], properties: [name]}
edges:
  Transfer:
    source: payments.transfers
    key: [id]
    from: {node: Account, columns: [src]}
    to: {node: Account, columns: [dst]}
    properties: [amount]

src and dst both point to Account.id. The transfer’s own id identifies the edge. Multiple rows can connect the same accounts when their transfer IDs differ.

3. Verify a known result

From the sample directory, run a query for account 1. Pass the account ID as a parameter so you can reuse the query for other accounts.

Shell
/opt/graphlake/current/bin/graphlake --catalog graph.yaml query \
  --parameters '{"account_id":1}' \
  'MATCH (a:Account)-[t:Transfer]->(b:Account)
WHERE a.id = $account_id
RETURN a.name AS sender, b.name AS recipient, t.amount AS amount
ORDER BY t.id'

Expected result Alice sent Bob 12.25. Change account_id to 3 to confirm Carol has no outgoing transfer.

Once this succeeds, use query recipes on the same files.

4. Bring the model into the console

From the same shell, use the sample directory as a separate catalog. Initialize its administrator password once, then start the packaged console on port 7347.

Shell
/opt/graphlake/current/bin/graphlake-admin --catalog-dir "$demo_dir" auth init
/opt/graphlake/current/bin/graphlake-admin --catalog-dir "$demo_dir" \
  --assets-dir /opt/graphlake/current/web --port 7347
  1. Open http://127.0.0.1:7347 and sign in as admin. If the service is on another machine, forward port 7347 over SSH.
  2. In Graph Models, verify that graph is published. Open Query, paste the earlier Cypher, and supply {"account_id":1} in Query options.

To use your own inputs, start from Connect data. Check key types and sample rows before you publish a mapping over production data.