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

Function subscribe

wasm/query.go:87–109  ·  view source on GitHub ↗
(gj *core.GraphJin)

Source from the content-addressed store, hash-verified

85}
86
87func 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
111func subscribeByName(gj *core.GraphJin) js.Func {
112 return js.FuncOf(func(this js.Value, args []js.Value) interface{} {

Callers 1

newGraphJinObjFunction · 0.85

Calls 5

processArgsFunction · 0.85
toJSErrorFunction · 0.85
fromMemberFunction · 0.85
toAwaitFunction · 0.85
SubscribeMethod · 0.45

Tested by

no test coverage detected