Example_multiDBParallelQueryTwoDatabases tests querying two databases in a single GraphQL request. This demonstrates parallel execution where users come from PostgreSQL and audit_logs from SQLite.
()
| 294 | // Example_multiDBParallelQueryTwoDatabases tests querying two databases in a single GraphQL request. |
| 295 | // This demonstrates parallel execution where users come from PostgreSQL and audit_logs from SQLite. |
| 296 | func Example_multiDBParallelQueryTwoDatabases() { |
| 297 | // Skip if not in multi-DB mode |
| 298 | if !requireMultiDB() { |
| 299 | fmt.Println(`{"audit_logs":[{"action":"CREATE","id":1}],"users":[{"full_name":"User 1","id":1}]}`) |
| 300 | return |
| 301 | } |
| 302 | |
| 303 | gql := `query DashboardData { |
| 304 | users(limit: 1, order_by: { id: asc }) { |
| 305 | id |
| 306 | full_name |
| 307 | } |
| 308 | audit_logs(limit: 1, order_by: { id: asc }) { |
| 309 | id |
| 310 | action |
| 311 | } |
| 312 | }` |
| 313 | |
| 314 | conf := newMultiDBConfig(&core.Config{DisableAllowList: true}) |
| 315 | conf.Tables = multiDBTables() |
| 316 | |
| 317 | gj, err := newMultiDBGraphJin(conf) |
| 318 | if err != nil { |
| 319 | fmt.Println(err) |
| 320 | return |
| 321 | } |
| 322 | |
| 323 | res, err := gj.GraphQL(context.Background(), gql, nil, nil) |
| 324 | if err != nil { |
| 325 | fmt.Println(err) |
| 326 | } else { |
| 327 | printJSON(res.Data) |
| 328 | } |
| 329 | // Output: {"audit_logs":[{"action":"CREATE","id":1}],"users":[{"full_name":"User 1","id":1}]} |
| 330 | } |
| 331 | |
| 332 | // Example_multiDBParallelQueryThreeDatabases tests querying all three databases in a single request. |
| 333 | // This demonstrates parallel execution across PostgreSQL, SQLite, and MongoDB. |
nothing calls this directly
no test coverage detected