pawanrawal commented :
I strongly suspect that you don’t have the correct schema. jurisdiction is not of list type in your schema. Can you share the output of doing the schema {} query? Here is some more code to illustrate that this works.
package main
import (
"context"
"fmt"
"log"
"testing"
"google.golang.org/grpc"
"github.com/dgraph-io/dgraph/client"
"github.com/dgraph-io/dgraph/protos/api"
"github.com/dgraph-io/dgraph/x"
)
func TestList(t *testing.T) {
d, err := grpc.Dial("localhost:9080", grpc.WithInsecure())
if err != nil {
log.Fatal(err)
}
c := client.NewDgraphClient(
api.NewDgraphClient(d),
)
ctx := context.Background()
x.Check(c.Alter(ctx, &api.Operation{DropAll: true}))
x.Check(c.Alter(ctx, &api.Operation{Schema: `
jurisdiction: [string] .
id: string @index(hash) .
`}))
out := []byte(`{"id":"c3acc43c-c635-475d-8bed-7c3b4f2af37d","type":"concept","term":"myTerm1","jurisdiction":["jur1","jur2"],"definition":"myDef1","lastUpdate":"2018-01-30T11:19:34.150"}`)
_, err = c.NewTxn().Mutate(context.Background(), &api.Mutation{SetJson: out, CommitNow: true})
x.Check(err)
q := `
{
concepts(func:eq(id, "c3acc43c-c635-475d-8bed-7c3b4f2af37d"))@recurse (depth: 2){
term
definition
jurisdiction
}
}
`
resp, err := c.NewTxn().Query(ctx, q)
x.Check(err)
fmt.Println(string(resp.Json))
}