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

Function Example_multiDBParallelQueryWithVariables

tests/multidb_test.go:375–411  ·  view source on GitHub ↗

Example_multiDBParallelQueryWithVariables tests parallel root queries with GraphQL variables.

()

Source from the content-addressed store, hash-verified

373
374// Example_multiDBParallelQueryWithVariables tests parallel root queries with GraphQL variables.
375func 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}

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