Get request returns unexpected/difficult to understand result

I’ve been playing around with Dgraph, and Go. I’ve got the following schema:

age: int .
name: string @index(exact) .
price: int .
buyerID: uid .
device: string .
id: string @index(exact, term) .
pid: string @index(exact) .
tid: string @index(exact) .
ip: string .
productIDs: [uid] .
<dgraph.drop.op>: string .
<dgraph.graphql.p_query>: string @index(sha256) .
<dgraph.graphql.schema>: string .
<dgraph.graphql.xid>: string @index(exact) @upsert .
type <Buyer> {
  id: string
  name: string
  age: int
type <Product> {
  pid: string
  name: string
  price: int
type Transaction {
  tid: string
  buyerID: uid
  ip: string
  device: string
  productIDs: [Person]
type <dgraph.graphql> {
type <dgraph.graphql.persisted_query> {

Which, after creating my connection I send in an api.Operation altering the database. Then, I obtain certain info corresponding to the following structs in Go

type Buyer struct {
	ID    string   `json:"id,omitempty"`
	Name  string   `json:"name,omitempty"`
	Age   int      `json:"age,omitempty"`
	Dtype []string `json:"dgraph.type,omitempty"`

type Product struct {
	PID   string   `json:"pid,omitempty"`
	Name  string   `json:"name,omitempty"`
	Price int      `json:"price,omitempty"`
	Dtype []string `json:"dgraph.type,omitempty"`

type Transaction struct {
	TID        string    `json:"tid,omitempty"`
	BuyerID    Buyer     `json:"buyer,omitempty"`
	IP         string    `json:"ip,omitempty"`
	Device     string    `json:"device,omitempty"`
	ProductIDs []Product `json:"products,omitempty"`
	Dtype      []string  `json:"dgraph.type,omitempty"`

No issue thus far, I run mutations adding info for both Buyer and Product adding. However, when looking to add transactions, my “input” has the ID but not the uid assigned by Dgraph. When trying to get the Buyer which corresponds to the specific Transaction, using this queryWithVars:

q := `query myQuery($a: string) {
		buyer(func: eq(id, $a)) {

the response.Json is just an array of bytes which I cannot comprehend. Running the same query from the Ratel UI does bring the expected JSON object. Is there any way to change the response, or is this some sort of error. Furthermore, the error obtained from the query is nil. Any ideas? At this point I’ve got no clue how to keep using dgo and get the Buyer.

The return type of the json is a []byte, but those bytes are just a json string. If you cast it to a string, you can print it out human-readably, or just json.unmarshal into your structs.

Also - welcome to the community :slight_smile:

Aaaaaa, thank you so much, yeah, the issue was that I did not attempt to cast it to a string, only unmarshal which still kind of not works, which I assume is because I do not obtain the DType as well, but thank you, really