Skip to content

Querying schema using gRpc client, returns empty object #23

@wildan2711

Description

@wildan2711

Tried querying schema with gRpc connection with this code:

        d, err := grpc.Dial("localhost:9080", grpc.WithInsecure())
	if err != nil {
		panic(err)
	}

	c := dgo.NewDgraphClient(
		api.NewDgraphClient(d),
	)
        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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions