Example_multiDBQueryPostgres tests querying the PostgreSQL database directly
()
| 37 | |
| 38 | // Example_multiDBQueryPostgres tests querying the PostgreSQL database directly |
| 39 | func Example_multiDBQueryPostgres() { |
| 40 | // Skip if not in multi-DB mode |
| 41 | if !requireMultiDB() { |
| 42 | fmt.Println(`{"users":[{"email":"user1@test.com","full_name":"User 1","id":1}]}`) |
| 43 | return |
| 44 | } |
| 45 | |
| 46 | gql := `query { |
| 47 | users(limit: 1, order_by: { id: asc }) { |
| 48 | id |
| 49 | full_name |
| 50 | |
| 51 | } |
| 52 | }` |
| 53 | |
| 54 | conf := newMultiDBConfig(&core.Config{DisableAllowList: true}) |
| 55 | conf.Tables = multiDBTables() |
| 56 | |
| 57 | gj, err := newMultiDBGraphJin(conf) |
| 58 | if err != nil { |
| 59 | fmt.Println(err) |
| 60 | return |
| 61 | } |
| 62 | |
| 63 | res, err := gj.GraphQL(context.Background(), gql, nil, nil) |
| 64 | if err != nil { |
| 65 | fmt.Println(err) |
| 66 | } else { |
| 67 | printJSON(res.Data) |
| 68 | } |
| 69 | // Output: {"users":[{"email":"user1@test.com","full_name":"User 1","id":1}]} |
| 70 | } |
| 71 | |
| 72 | // Example_multiDBQuerySQLite tests querying the SQLite database |
| 73 | func Example_multiDBQuerySQLite() { |
nothing calls this directly
no test coverage detected