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

Function query

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

Source from the content-addressed store, hash-verified

12)
13
14func 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{} {

Callers 1

newGraphJinObjFunction · 0.70

Calls 5

processArgsFunction · 0.85
toJSErrorFunction · 0.85
fromResultFunction · 0.85
toAwaitFunction · 0.85
GraphQLMethod · 0.45

Tested by

no test coverage detected