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

Method GraphQLByName

core/api.go:788–812  ·  view source on GitHub ↗

GraphQLByName is similar to the GraphQL function except that queries saved in the queries folder can directly be used just by their name (filename).

(c context.Context,
	name string,
	vars json.RawMessage,
	rc *RequestConfig,
)

Source from the content-addressed store, hash-verified

786// GraphQLByName is similar to the GraphQL function except that queries saved
787// in the queries folder can directly be used just by their name (filename).
788func (g *GraphJin) GraphQLByName(c context.Context,
789 name string,
790 vars json.RawMessage,
791 rc *RequestConfig,
792) (res *Result, err error) {
793 gj, err := g.getEngine()
794 if err != nil {
795 return
796 }
797
798 c1, span := gj.spanStart(c, "GraphJin Query")
799 defer span.End()
800
801 item, err := gj.allowList.GetByName(name, gj.prod)
802 if err != nil {
803 err = fmt.Errorf("%w: %s", err, name)
804 return
805 }
806
807 r := gj.newGraphqlReq(rc, "", name, nil, vars)
808 r.Set(item)
809
810 res, err = gj.queryWithResult(c1, r)
811 return
812}
813
814// GraphQLByNameTx is similiar to the GraphQLByName function except
815// that it can be used within a database transactions.

Callers 5

GraphQLByNameTxMethod · 0.95
TestAllowListFunction · 0.95
queryByNameFunction · 0.80
apiV1RestMethod · 0.80

Calls 7

getEngineMethod · 0.95
GetByNameMethod · 0.80
newGraphqlReqMethod · 0.80
queryWithResultMethod · 0.80
EndMethod · 0.65
SetMethod · 0.65
spanStartMethod · 0.45

Tested by 1

TestAllowListFunction · 0.76