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

Function Example_multiDBQuerySQLite

tests/multidb_test.go:73–104  ·  view source on GitHub ↗

Example_multiDBQuerySQLite tests querying the SQLite database

()

Source from the content-addressed store, hash-verified

71
72// Example_multiDBQuerySQLite tests querying the SQLite database
73func Example_multiDBQuerySQLite() {
74 // Skip if not in multi-DB mode
75 if !requireMultiDB() {
76 fmt.Println(`{"audit_logs":[{"action":"CREATE","entity_type":"product","id":1}]}`)
77 return
78 }
79
80 gql := `query {
81 audit_logs(limit: 1, order_by: { id: asc }) {
82 id
83 action
84 entity_type
85 }
86 }`
87
88 conf := newMultiDBConfig(&core.Config{DisableAllowList: true})
89 conf.Tables = multiDBTables()
90
91 gj, err := newMultiDBGraphJin(conf)
92 if err != nil {
93 fmt.Println(err)
94 return
95 }
96
97 res, err := gj.GraphQL(context.Background(), gql, nil, nil)
98 if err != nil {
99 fmt.Println(err)
100 } else {
101 printJSON(res.Data)
102 }
103 // Output: {"audit_logs":[{"action":"CREATE","entity_type":"product","id":1}]}
104}
105
106// Example_multiDBQueryMongoDB tests querying the MongoDB database
107func Example_multiDBQueryMongoDB() {

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