I ran a case from the official document and created a schema using dgo, but the result was an error
conn, err := grpc.Dial("192.168.1.252:9080", grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
fmt.Println(err.Error())
return
}
defer func() {
_ = conn.Close()
}()
dgraphClient := dgo.NewDgraphClient(api.NewDgraphClient(conn))
dqlTxt := `type Product {
productID: ID!
name: String @search(by: [term])
reviews: [Review] @hasInverse(field: about)
}
type Customer {
username: String! @id @search(by: [hash, regexp])
reviews: [Review] @hasInverse(field: by)
}
type Review {
id: ID!
about: Product!
by: Customer!
comment: String @search(by: [fulltext])
rating: Int @search
}`
op := api.Operation{
Schema: dqlTxt,
RunInBackground: true,
}
err1 := dgraphClient.Alter(context.Background(), &op)
if err1 != nil {
fmt.Println(err1.Error())
}
}
The error content is
rpc error: code = Unknown desc = line 3 column 17: Expected new line after field declaration. Got @