Rpc error: code = Unimplemented desc = unknown method Mutate for service api.Dgraph

Hello, I couldn’t find any hits when googling the error with regard to unknown method Mutate.

This is my docker-compose file:

version: "3.2"
services:
  zero:
    image: dgraph/dgraph:latest
    volumes:
      - type: volume
        source: dgraph
        target: /dgraph
        volume:
          nocopy: true
    ports:
      - 5080:5080
      - 6080:6080
    restart: on-failure
    command: dgraph zero --my=zero:5080
  server:
    image: dgraph/dgraph:latest
    volumes:
      - type: volume
        source: dgraph
        target: /dgraph
        volume:
          nocopy: true
    ports:
      - 8080:8080
      - 9080:9080
    restart: on-failure
    command: dgraph alpha --my=server:7080 --lru_mb=2048 --zero=zero:5080 --whitelist 172.23.0.1,192.168.1.1
  ratel:
    image: dgraph/dgraph:latest
    volumes:
      - type: volume
        source: dgraph
        target: /dgraph
        volume:
          nocopy: true
    ports:
      - 8000:8000
    command: dgraph-ratel

volumes:
  dgraph:

I establish connection on address 127.0.0.1:9080 and I’m using go module github.com/dgraph-io/dgo v1.0.0 .

Any help would be much appreciated :slight_smile:

the same problem ,any one resolve it ?

Could you share part of the code that is causing the issue so that I can reproduce the issue on my end?

This gives me rpc error: code = Unimplemented desc = unknown method Mutate for service api.Dgraph:

package main

import (
	"context"
	"encoding/json"

	"github.com/dgraph-io/dgo"
	"github.com/dgraph-io/dgo/protos/api"
	"google.golang.org/grpc"
)

type Person struct {
	UID  string `json:"uid"`
	Name string `json:"name"`
}

func main() {
	conn, err := grpc.Dial("127.0.0.1:9080", grpc.WithInsecure())
	if err != nil {
		panic(err)
	}
	client := dgo.NewDgraphClient(api.NewDgraphClient(conn))

	person := Person{
		Name: "Alice",
	}
	plainJSON, err := json.Marshal(person)
	if err != nil {
		panic(err)
	}
	mut := &api.Mutation{
		CommitNow: true,
		SetJson:   plainJSON,
	}
	_, err = client.NewTxn().Mutate(context.Background(), mut)
	if err != nil {
		panic(err)
	}
}

And my go mod file:

module github.com/test/test

go 1.12

require (
	github.com/dgraph-io/dgo v1.0.0
	golang.org/x/net v0.0.0-20190921015927-1a5e07d1ff72 // indirect
	golang.org/x/sys v0.0.0-20190922100055-0a153f010e69 // indirect
	golang.org/x/text v0.3.2 // indirect
	google.golang.org/genproto v0.0.0-20190916214212-f660b8655731 // indirect
	google.golang.org/grpc v1.23.1
)

As the README says, dgo 2.0 is only compatible with dgraph 1.1. You will have to change the import in your code to -

github.com/dgraph-io/dgo/v2
github.com/dgraph-io/dgo/v2/protos/api
2 Likes

Oh wow, seems like there has been quite a few changed along with the new Type system… It’s working now, thanks :smile:

1 Like

wow ,it works well ,thank you very much

1 Like

yeap, I too was experiencing the same problem and given solution works :slight_smile:

I am using VSC and while going through client tutorial I relied on suggested imports thrown at me.

Hi!

Im getting the same error with Dgraph4j, version 1.3.0. Any help?!

Exception in thread "main" io.grpc.StatusRuntimeException: UNIMPLEMENTED: unknown method Mutate for service api.Dgraph

Thanks! :pray:

Aman’s answer above applies to all the clients. If you are using dgraph 1.1, you need a newer version of the client since there are breaking changes in the API.