# Error: code = Unknown desc = Operation must have at least one field set

**URL:** <https://discuss.dgraph.io/t/error-code-unknown-desc-operation-must-have-at-least-one-field-set/5069>\
**Category:** Dgraph\
**Created:** [September 14, 2019, 10:58am UTC](https://discuss.dgraph.io/t/error-code-unknown-desc-operation-must-have-at-least-one-field-set/5069 "2019-09-14T10:58:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mehrdad.dev](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mehrdad.dev/32/2744_2.png) [@mehrdad.dev](https://discuss.dgraph.io/u/mehrdad.dev)\
**Post date:** [September 14, 2019, 10:58am UTC](https://discuss.dgraph.io/t/error-code-unknown-desc-operation-must-have-at-least-one-field-set/5069/1 "2019-09-14T10:58:10Z")

</div>

Hi  
#golang #dgo #go  
I create a func mutate in go for mutate the RDF ,  
and send argument from main to func mutate

**my code :**

```auto
package main

import (
    "context"
    "log"
    "fmt"
    "github.com/dgraph-io/dgo"
    "github.com/dgraph-io/dgo/protos/api"
    "google.golang.org/grpc"
)

func mutate(dg *dgo.Dgraph, ctx context.Context) {
    mu := &api.Mutation{
        CommitNow: true,
    }
    p := `
        _:person1 <UrlName> "mahdi999" .
        _:person2 <UrlName> "ali" .
    `
    mu.SetNquads = []byte(p)
    _, err := dg.NewTxn().Mutate(ctx, mu)
    if err != nil {
        log.Fatal(err)
    }
    resp, err := dg.NewTxn().Query(context.Background(), `{
    find(func: has(UrlName)) {
        UrlName
    }
    }`)
  
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Response: %s\n", resp.Json)
}

func main() {
    conn, err := grpc.Dial("127.0.0.1:9080", grpc.WithInsecure())
    if err != nil {
        log.Fatal("trying to dial gRPC")
    }
    defer conn.Close()

    dc := api.NewDgraphClient(conn)
    dg := dgo.NewDgraphClient(dc)

    op := &api.Operation{} // DropAll : true
    ctx := context.Background()
    err = dg.Alter(ctx, op)
    if err != nil {
        log.Fatal(err)
    }
    mutate(dg , ctx)
}

```

But when run the go show this error :

```auto
2019/09/14 15:19:20 rpc error: code = Unknown desc = Operation must have at least one field set
exit status 1

```

**Can you help me ?!**

---

<div class="post-metadata">

**Author:** ![amanmangal](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amanmangal/32/1249_2.png) [@amanmangal](https://discuss.dgraph.io/u/amanmangal)\
**Post date:** [September 14, 2019, 6:29pm UTC](https://discuss.dgraph.io/t/error-code-unknown-desc-operation-must-have-at-least-one-field-set/5069/2 "2019-09-14T18:29:11Z")

</div>

> [@mehrdad.dev](#):
>
> op := &api.Operation{}

`op := api.Operation{DropAll: true}`

---

<div class="post-metadata">

**Author:** ![mehrdad.dev](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mehrdad.dev/32/2744_2.png) [@mehrdad.dev](https://discuss.dgraph.io/u/mehrdad.dev)\
**Post date:** [September 15, 2019, 7:48am UTC](https://discuss.dgraph.io/t/error-code-unknown-desc-operation-must-have-at-least-one-field-set/5069/3 "2019-09-15T07:48:26Z")

</div>

i don’t want drop all data .  
how to don’t drop data and mutate in dgraph with go .  
in python i can mutate and don’t drop data in database .

---

<div class="post-metadata">

**Author:** ![ppp225](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/ppp225/32/2007_2.png) [@ppp225](https://discuss.dgraph.io/u/ppp225)\
**Post date:** [September 15, 2019, 8:19am UTC](https://discuss.dgraph.io/t/error-code-unknown-desc-operation-must-have-at-least-one-field-set/5069/4 "2019-09-15T08:19:02Z")

</div>

How about not running `dg.Alter(ctx, op)` at all? You shouldn’t need it if you just want to mutate.
