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

Function queryByName

wasm/query.go:62–85  ·  view source on GitHub ↗

func queryWithTx(gj *core.GraphJin) js.Func { return js.FuncOf(func(this js.Value, args []js.Value) interface{} { var qa queryArgs if err := processArgsWithTx(&qa, args, "query"); !err.IsUndefined() { return err } c := context.TODO() if qa.userID != nil { c = context.WithValue(c, co

(gj *core.GraphJin)

Source from the content-addressed store, hash-verified

60// }
61
62func queryByName(gj *core.GraphJin) js.Func {
63 return js.FuncOf(func(this js.Value, args []js.Value) interface{} {
64 var qa queryArgs
65 if err := processArgs(&qa, args, "name"); !err.IsUndefined() {
66 return err
67 }
68
69 c := context.TODO()
70
71 if qa.userID != nil {
72 c = context.WithValue(c, core.UserIDKey, qa.userID)
73 }
74
75 fn := func(resolve, reject js.Value) {
76 res, err := gj.GraphQLByName(c, qa.query, qa.vars, nil)
77 if err != nil {
78 reject.Invoke(toJSError(err))
79 } else {
80 resolve.Invoke(fromResult(res))
81 }
82 }
83 return toAwait(fn)
84 })
85}
86
87func subscribe(gj *core.GraphJin) js.Func {
88 return js.FuncOf(func(this js.Value, args []js.Value) interface{} {

Callers 1

newGraphJinObjFunction · 0.85

Calls 5

processArgsFunction · 0.85
toJSErrorFunction · 0.85
fromResultFunction · 0.85
toAwaitFunction · 0.85
GraphQLByNameMethod · 0.80

Tested by

no test coverage detected