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

Method GetCurrentUser

dgraphapi/acl.go:63–84  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

61}
62
63func (hc *HTTPClient) GetCurrentUser() (string, error) {
64 const query = `query {
65 getCurrentUser {
66 name
67 }
68 }`
69 params := GraphQLParams{Query: query}
70 resp, err := hc.RunGraphqlQuery(params, true)
71 if err != nil {
72 return "", errors.Wrapf(err, "received response: %v", string(resp))
73 }
74
75 var userResp struct {
76 GetCurrentUser struct {
77 Name string
78 }
79 }
80 if err := json.Unmarshal(resp, &userResp); err != nil {
81 return "", errors.Wrapf(err, "error unmarshalling getCurrentUser response")
82 }
83 return userResp.GetCurrentUser.Name, nil
84}
85
86func (hc *HTTPClient) DeleteUser(username string) error {
87 const query = `mutation deleteUser($name: String!) {

Callers 2

TestGetCurrentUserMethod · 0.80
TestInvalidGetUserMethod · 0.80

Calls 1

RunGraphqlQueryMethod · 0.95

Tested by 2

TestGetCurrentUserMethod · 0.64
TestInvalidGetUserMethod · 0.64