(gj *core.GraphJin)
| 12 | ) |
| 13 | |
| 14 | func query(gj *core.GraphJin) js.Func { |
| 15 | return js.FuncOf(func(this js.Value, args []js.Value) interface{} { |
| 16 | var qa queryArgs |
| 17 | if err := processArgs(&qa, args, "query"); !err.IsUndefined() { |
| 18 | return err |
| 19 | } |
| 20 | |
| 21 | c := context.TODO() |
| 22 | if qa.userID != nil { |
| 23 | c = context.WithValue(c, core.UserIDKey, qa.userID) |
| 24 | } |
| 25 | |
| 26 | fn := func(resolve, reject js.Value) { |
| 27 | res, err := gj.GraphQL(c, qa.query, qa.vars, nil) |
| 28 | if err != nil { |
| 29 | reject.Invoke(toJSError(err)) |
| 30 | } else { |
| 31 | resolve.Invoke(fromResult(res)) |
| 32 | } |
| 33 | } |
| 34 | return toAwait(fn) |
| 35 | }) |
| 36 | } |
| 37 | |
| 38 | // func queryWithTx(gj *core.GraphJin) js.Func { |
| 39 | // return js.FuncOf(func(this js.Value, args []js.Value) interface{} { |
no test coverage detected