MCPcopy Index your code
hub / github.com/dosco/graphjin / Example_multiDBParallelQueryTwoDatabases

Function Example_multiDBParallelQueryTwoDatabases

tests/multidb_test.go:296–330  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

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.
296func 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.

Callers

nothing calls this directly

Calls 6

requireMultiDBFunction · 0.85
newMultiDBConfigFunction · 0.85
multiDBTablesFunction · 0.85
newMultiDBGraphJinFunction · 0.85
printJSONFunction · 0.85
GraphQLMethod · 0.45

Tested by

no test coverage detected