MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / RunGraphqlQuery

Method RunGraphqlQuery

dgraphapi/cluster.go:274–299  ·  view source on GitHub ↗

RunGraphqlQuery makes a query to graphql (or admin) endpoint

(params GraphQLParams, admin bool)

Source from the content-addressed store, hash-verified

272
273// RunGraphqlQuery makes a query to graphql (or admin) endpoint
274func (hc *HTTPClient) RunGraphqlQuery(params GraphQLParams, admin bool) ([]byte, error) {
275 reqBody, err := json.Marshal(params)
276 if err != nil {
277 return nil, errors.Wrap(err, "error while marshalling params")
278 }
279
280 url := hc.graphqlURL
281 if admin {
282 url = hc.adminURL
283 }
284
285 respBody, err := hc.doPost(reqBody, url, "application/json")
286 if err != nil {
287 return nil, errors.Wrap(err, "error while running graphql query")
288 }
289
290 var gqlResp GraphQLResponse
291 if err := json.Unmarshal(respBody, &gqlResp); err != nil {
292 return nil, errors.Wrap(err, "error unmarshalling GQL response")
293 }
294 if len(gqlResp.Errors) > 0 {
295 return nil, errors.Wrapf(gqlResp.Errors, "error while running graphql query, resp: %v",
296 string(gqlResp.Data))
297 }
298 return gqlResp.Data, nil
299}
300
301func (hc *HTTPClient) HealthForInstance() ([]byte, error) {
302 const query = `query {

Callers 15

CreateUserMethod · 0.95
GetCurrentUserMethod · 0.95
DeleteUserMethod · 0.95
CreateGroupMethod · 0.95
CreateGroupWithRulesMethod · 0.95
DeleteGroupMethod · 0.95
AddRulesToGroupMethod · 0.95
AddUserToGroupMethod · 0.95
RemoveUserFromGroupMethod · 0.95
UpdateGroupMethod · 0.95
AddNamespaceMethod · 0.95

Calls 1

doPostMethod · 0.95