Example_multiDBParallelQueryThreeDatabases tests querying all three databases in a single request. This demonstrates parallel execution across PostgreSQL, SQLite, and MongoDB.
()
| 332 | // Example_multiDBParallelQueryThreeDatabases tests querying all three databases in a single request. |
| 333 | // This demonstrates parallel execution across PostgreSQL, SQLite, and MongoDB. |
| 334 | func Example_multiDBParallelQueryThreeDatabases() { |
| 335 | // Skip if not in multi-DB mode |
| 336 | if !requireMultiDB() { |
| 337 | fmt.Println(`{"audit_logs":[{"action":"CREATE","id":1}],"events":[{"id":1,"type":"page_view"}],"users":[{"full_name":"User 1","id":1}]}`) |
| 338 | return |
| 339 | } |
| 340 | |
| 341 | gql := `query FullDashboard { |
| 342 | users(limit: 1, order_by: { id: asc }) { |
| 343 | id |
| 344 | full_name |
| 345 | } |
| 346 | audit_logs(limit: 1, order_by: { id: asc }) { |
| 347 | id |
| 348 | action |
| 349 | } |
| 350 | events(limit: 1, order_by: { id: asc }) { |
| 351 | id |
| 352 | type |
| 353 | } |
| 354 | }` |
| 355 | |
| 356 | conf := newMultiDBConfig(&core.Config{DisableAllowList: true}) |
| 357 | conf.Tables = multiDBTables() |
| 358 | |
| 359 | gj, err := newMultiDBGraphJin(conf) |
| 360 | if err != nil { |
| 361 | fmt.Println(err) |
| 362 | return |
| 363 | } |
| 364 | |
| 365 | res, err := gj.GraphQL(context.Background(), gql, nil, nil) |
| 366 | if err != nil { |
| 367 | fmt.Println(err) |
| 368 | } else { |
| 369 | printJSON(res.Data) |
| 370 | } |
| 371 | // Output: {"audit_logs":[{"action":"CREATE","id":1}],"events":[{"id":1,"type":"page_view"}],"users":[{"full_name":"User 1","id":1}]} |
| 372 | } |
| 373 | |
| 374 | // Example_multiDBParallelQueryWithVariables tests parallel root queries with GraphQL variables. |
| 375 | func Example_multiDBParallelQueryWithVariables() { |
nothing calls this directly
no test coverage detected