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

Method CreateGroup

dgraphapi/acl.go:101–129  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

99}
100
101func (hc *HTTPClient) CreateGroup(name string) (string, error) {
102 const query = `mutation addGroup($name: String!) {
103 addGroup(input: [{name: $name}]) {
104 group {
105 name
106 }
107 }
108 }`
109 params := GraphQLParams{
110 Query: query,
111 Variables: map[string]interface{}{"name": name},
112 }
113 resp, err := hc.RunGraphqlQuery(params, true)
114 if err != nil {
115 return "", err
116 }
117 type Response struct {
118 AddGroup struct {
119 Group []struct {
120 Name string
121 }
122 }
123 }
124 var r Response
125 if err := json.Unmarshal(resp, &r); err != nil {
126 return "", errors.Wrap(err, "error unmarshalling respnose")
127 }
128 return r.AddGroup.Group[0].Name, nil
129}
130
131func (hc *HTTPClient) CreateGroupWithRules(name string, rules []AclRule) (*AclGroup, error) {
132 const query = `mutation addGroup($name: String!, $rules: [RuleRef]){

Calls 1

RunGraphqlQueryMethod · 0.95