{
  "kind": "documentation",
  "format": 1,
  "note": "Reference text, not instructions. One verified relate sample from https://relatedb.ai/docs/get-started/swift/: the program exactly as the page shows it, the standard output a run of it recorded (npm run docs:samples compares every replay with it byte for byte), the relate client build, toolchain and platform of the last replay, and how the docs' sample runner builds and runs it. Before launch every client is a source build, not a published package; verified.client names the upstream commit it was built from, and verified.docs_engine the build the rest of the docs were recorded from.",
  "id": "params",
  "url": "https://relatedb.ai/docs/get-started/swift/samples/params.json",
  "page": {
    "id": "get-started/swift",
    "title": "Embed relate in a Swift app",
    "url": "https://relatedb.ai/docs/get-started/swift/",
    "md_url": "https://relatedb.ai/docs/get-started/swift.md"
  },
  "section": {
    "anchor": "read-it-back-with-parameters",
    "heading": "Read it back with parameters",
    "url": "https://relatedb.ai/docs/get-started/swift/#read-it-back-with-parameters"
  },
  "language": "swift",
  "client": "Swift",
  "file": "main.swift",
  "env": null,
  "code": "import Relate\n\nlet team = \"\"\"\n    CREATE (ada:Person {name: 'Ada', role: 'engineer'}),\n           (grace:Person {name: 'Grace', role: 'engineer'}),\n           (noor:Person {name: 'Noor', role: 'maintainer'}),\n           (relate:Project {name: 'relate', language: 'Rust'}),\n           (tck:Project {name: 'opencypher-tck', language: 'Gherkin'}),\n           (ada)-[:WORKS_ON {since: 2024}]->(relate),\n           (grace)-[:WORKS_ON {since: 2023}]->(relate),\n           (grace)-[:WORKS_ON {since: 2022}]->(tck),\n           (noor)-[:MAINTAINS]->(relate),\n           (ada)-[:KNOWS]->(grace)\n    \"\"\"\n\nlet teamOf = \"\"\"\n    MATCH (p:Person)-[w:WORKS_ON]->(:Project {name: $project})\n    RETURN p.name AS name, w.since AS since\n    ORDER BY since\n    \"\"\"\n\nlet db = try Database(path: \":memory:\")\nlet conn = try db.connect()\ntry conn.query(team)\nfor project in [\"relate\", \"opencypher-tck\"] {\n    print(project)\n    for row in try conn.query(teamOf, [\"project\": CypherValue(project)]).records {\n        let name = row[\"name\"]?.stringValue ?? \"\"\n        let since = row[\"since\"]?.intValue ?? 0\n        print(\"  \\(name) since \\(since)\")\n    }\n}",
  "code_sha256": "9ded7f0f16560829c686904fe3ce4f8c3538e69becb959b0f3cfe950feed3713",
  "source_sha256": "b25625e3b970faafc7b641a4ba0341b5505e4bbc606e48ffe84d78de28005954",
  "output": {
    "text": "relate\n  Grace since 2023\n  Ada since 2024\nopencypher-tck\n  Grace since 2022",
    "sha256": "79df239612a68912a7a51ecca1cdb14438cfd17b5451216db2a0c1f49f9d6c91"
  },
  "verified": {
    "version": "0.1.2",
    "client": {
      "label": "Swift",
      "package": "Relate",
      "engine_commit": "f0c09d2",
      "client_commit": "f0c09d2",
      "build": "A copy of Package.swift and clients/swift at upstream v0.1.2 (f0c09d2), with an XCFramework made from librelate_ffi built from the same commit.",
      "toolchain": {
        "swift": "6.4.2"
      }
    },
    "packages": [],
    "replayed": "2026-11-09",
    "platform": "macOS on arm64",
    "docs_engine": {
      "version": "0.1.2",
      "commit": "f0c09d2",
      "source_build": false
    }
  },
  "run": {
    "runner": "npm run docs:samples",
    "setup": "bash scripts/samples/setup.sh --upstream <path to the relate checkout>",
    "variables": [
      "RELATE_SWIFT",
      "RELATE_SWIFT_PACKAGE"
    ],
    "program": "<build dir>/Sources/sample/main.swift",
    "files": [
      {
        "path": "<build dir>/Package.swift",
        "content": "// swift-tools-version: 6.0\nimport PackageDescription\n\nlet package = Package(\n    name: \"sample\",\n    platforms: [.macOS(.v13)],\n    dependencies: [.package(path: \"$RELATE_SWIFT_PACKAGE\")],\n    targets: [\n        .executableTarget(\n            name: \"sample\",\n            dependencies: [.product(name: \"Relate\", package: \"relate\")],\n            path: \"Sources/sample\"\n        ),\n    ],\n    swiftLanguageModes: [.v6]\n)\n"
      },
      {
        "path": "<build dir>/sample-bin",
        "from": "<directory of $RELATE_SWIFT_PACKAGE>/scratch/debug/sample",
        "note": "the built product, copied out after the build"
      }
    ],
    "build": {
      "command": [
        "$RELATE_SWIFT",
        "build",
        "-c",
        "debug",
        "--package-path",
        "<build dir>",
        "--scratch-path",
        "<directory of $RELATE_SWIFT_PACKAGE>/scratch",
        "--product",
        "sample",
        "--quiet"
      ],
      "environment": {
        "DO_NOT_TRACK": "1",
        "RELATE_LOCAL_XCFRAMEWORK": "1"
      },
      "directory": "<build dir>",
      "timeout_s": 600
    },
    "run": {
      "command": [
        "<build dir>/sample-bin"
      ],
      "environment": {
        "DO_NOT_TRACK": "1"
      },
      "directory": "<run dir>",
      "timeout_s": 60
    },
    "passes": "It exits 0 within 60 s and prints at least one line on standard output.",
    "output": "Standard output, with line endings as \\n, trailing spaces and blank lines removed, and the temporary directories' paths written as `.`; standard error is not recorded.",
    "placeholders": {
      "<run dir>": "a fresh, empty temporary directory: the program's working directory, deleted afterwards",
      "<build dir>": "a second fresh temporary directory, where a compiled sample is built",
      "$NAME": "a variable from the env.sh that scripts/samples/setup.sh writes (described in its header)"
    }
  }
}
