Example_multiDBParallelQueryWithVariables tests parallel root queries with GraphQL variables.
()
| 373 | |
| 374 | // Example_multiDBParallelQueryWithVariables tests parallel root queries with GraphQL variables. |
| 375 | func Example_multiDBParallelQueryWithVariables() { |
| 376 | // Skip if not in multi-DB mode |
| 377 | if !requireMultiDB() { |
| 378 | fmt.Println(`{"audit_logs":[{"action":"CREATE","id":1}],"users":[{"full_name":"User 1","id":1},{"full_name":"User 2","id":2}]}`) |
| 379 | return |
| 380 | } |
| 381 | |
| 382 | gql := `query FilteredDashboard($userLimit: Int!, $logLimit: Int!) { |
| 383 | users(limit: $userLimit, order_by: { id: asc }) { |
| 384 | id |
| 385 | full_name |
| 386 | } |
| 387 | audit_logs(limit: $logLimit, order_by: { id: asc }) { |
| 388 | id |
| 389 | action |
| 390 | } |
| 391 | }` |
| 392 | |
| 393 | vars := json.RawMessage(`{"userLimit": 2, "logLimit": 1}`) |
| 394 | |
| 395 | conf := newMultiDBConfig(&core.Config{DisableAllowList: true}) |
| 396 | conf.Tables = multiDBTables() |
| 397 | |
| 398 | gj, err := newMultiDBGraphJin(conf) |
| 399 | if err != nil { |
| 400 | fmt.Println(err) |
| 401 | return |
| 402 | } |
| 403 | |
| 404 | res, err := gj.GraphQL(context.Background(), gql, vars, nil) |
| 405 | if err != nil { |
| 406 | fmt.Println(err) |
| 407 | } else { |
| 408 | printJSON(res.Data) |
| 409 | } |
| 410 | // Output: {"audit_logs":[{"action":"CREATE","id":1}],"users":[{"full_name":"User 1","id":1},{"full_name":"User 2","id":2}]} |
| 411 | } |
nothing calls this directly
no test coverage detected