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

Function Example_setArrayColumnToValue

tests/update_test.go:234–262  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

232}
233
234func Example_setArrayColumnToValue() {
235 gql := `mutation {
236 products(where: { id: 100 }, update: { tags: ["super", "great", "wow"] }) {
237 id
238 tags
239 }
240 }`
241
242 conf := newConfig(&core.Config{DBType: dbType, DisableAllowList: true})
243 gj, err := core.NewGraphJin(conf, db)
244 if err != nil {
245 panic(err)
246 }
247 defer gj.Close()
248
249 ctx := context.WithValue(context.Background(), core.UserIDKey, 3)
250 res, err := gj.GraphQL(ctx, gql, nil, nil)
251 if err != nil {
252 logSnowflakeQueryFailure(gj, gql, nil, err)
253 fmt.Println(err)
254 } else {
255 printJSON(res.Data)
256 }
257
258 // Cleanup: restore tags to original state
259 _, _ = db.Exec(`UPDATE products SET tags = list_value('Tag 1', 'Tag 2', 'Tag 3', 'Tag 4', 'Tag 5') WHERE id = 100`)
260
261 // Output: {"products":[{"id":100,"tags":["super","great","wow"]}]}
262}
263
264func Example_setArrayColumnToEmpty() {
265 gql := `mutation {

Callers

nothing calls this directly

Calls 6

CloseMethod · 0.95
GraphQLMethod · 0.95
newConfigFunction · 0.85
logSnowflakeQueryFailureFunction · 0.85
printJSONFunction · 0.85
ExecMethod · 0.65

Tested by

no test coverage detected