MCPcopy
hub / github.com/dosco/graphjin / Example_multiDBParallelQueryThreeDatabases

Function Example_multiDBParallelQueryThreeDatabases

tests/multidb_test.go:334–372  ·  view source on GitHub ↗

Example_multiDBParallelQueryThreeDatabases tests querying all three databases in a single request. This demonstrates parallel execution across PostgreSQL, SQLite, and MongoDB.

()

Source from the content-addressed store, hash-verified

332// Example_multiDBParallelQueryThreeDatabases tests querying all three databases in a single request.
333// This demonstrates parallel execution across PostgreSQL, SQLite, and MongoDB.
334func 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.
375func Example_multiDBParallelQueryWithVariables() {

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