Querying schema using gRpc client, returns empty object


(Wildan Maulana Syahidillah) #1

I’m using the dgo client library.

Tried querying schema with gRpc connection with this code:

        schemaQuery := `
		schema {
			type
			index
			reverse
			tokenizer
			list
			count
			upsert
			lang
		}
	`

	tx := c.NewTxn()
	resp, err := tx.Query(context.Background(), schemaQuery)
	if err != nil {
		return nil, err
	}

	var queryResult struct {
		Data []Schema
	}
	log.Println((string(resp.Json))

All it logs is just an empty object {}.

Tried querying using HTTP, seems to return schema as normal.

~$ curl -X POST localhost:8080/query -d $'
schema {
type
index
reverse
tokenizer
list
count
upsert
lang
}' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   409  100   346  100    63   5792   1054 --:--:-- --:--:-- --:--:--  5965
{
  "data": {
    "schema": [
      {
        "predicate": "_predicate_",
        "type": "string",
        "list": true
      },
      {
        "predicate": "email",
        "type": "string",
        "index": true,
        "tokenizer": [
          "hash"
        ]
      },
      {
        "predicate": "password",
        "type": "string"
      },
      {
        "predicate": "username",
        "type": "string",
        "index": true,
        "tokenizer": [
          "hash"
        ]
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "encoding_ns": 1777000
    },
    "txn": {
      "start_ts": 30036
    }
  }
}

Any issue with the gRpc client?


(Daniel Mai) #2

That does look like a bug. I see you also posted a GitHub issue for dgo. Let’s continue the discussion there.


(Daniel Mai) #3

Ah, the api.Response that’s returned in the query has .Schema field that should be checked instead of the .Json field.


(Wildan Maulana Syahidillah) #4

Thanks for clarifying and it to the docs!