(gj *core.GraphJin)
| 85 | } |
| 86 | |
| 87 | func subscribe(gj *core.GraphJin) js.Func { |
| 88 | return js.FuncOf(func(this js.Value, args []js.Value) interface{} { |
| 89 | var qa queryArgs |
| 90 | if err := processArgs(&qa, args, "query"); !err.IsUndefined() { |
| 91 | return err |
| 92 | } |
| 93 | |
| 94 | c := context.TODO() |
| 95 | if qa.userID != nil { |
| 96 | c = context.WithValue(c, core.UserIDKey, qa.userID) |
| 97 | } |
| 98 | |
| 99 | fn := func(resolve, reject js.Value) { |
| 100 | res, err := gj.Subscribe(c, qa.query, qa.vars, nil) |
| 101 | if err != nil { |
| 102 | reject.Invoke(toJSError(err)) |
| 103 | } else { |
| 104 | resolve.Invoke(fromMember(res)) |
| 105 | } |
| 106 | } |
| 107 | return toAwait(fn) |
| 108 | }) |
| 109 | } |
| 110 | |
| 111 | func subscribeByName(gj *core.GraphJin) js.Func { |
| 112 | return js.FuncOf(func(this js.Value, args []js.Value) interface{} { |
no test coverage detected